Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2699 → Rev 2700

/trunk/uspace/lib/libc/generic/vfs.c
95,8 → 95,7
return (int) rc;
}
 
 
int open(const char *path, int oflag, ...)
static int _open(const char *path, int lflag, int oflag, ...)
{
int res;
ipcarg_t rc;
113,7 → 112,7
return res;
}
}
req = async_send_2(vfs_phone, VFS_OPEN, oflag, 0, &answer);
req = async_send_3(vfs_phone, VFS_OPEN, lflag, oflag, 0, &answer);
rc = ipc_data_write_start(vfs_phone, path, strlen(path));
if (rc != EOK) {
async_wait_for(req, NULL);
127,6 → 126,11
return (int) IPC_GET_ARG1(answer);
}
 
int open(const char *path, int oflag, ...)
{
return _open(path, L_FILE, oflag);
}
 
ssize_t read(int fildes, void *buf, size_t nbyte)
{
int res;
242,7 → 246,7
DIR *dirp = malloc(sizeof(DIR));
if (!dirp)
return NULL;
dirp->fd = open(dirname, 0); /* TODO: must be a directory */
dirp->fd = _open(dirname, L_DIRECTORY, 0);
if (dirp->fd < 0) {
free(dirp);
return NULL;
/trunk/uspace/srv/fs/tmpfs/tmpfs_ops.c
236,6 → 236,7
unsigned next = IPC_GET_ARG1(*request);
unsigned last = IPC_GET_ARG2(*request);
int dev_handle = IPC_GET_ARG3(*request);
int lflag = IPC_GET_ARG4(*request);
 
if (last < next)
last += PLB_SIZE;
/trunk/uspace/srv/vfs/vfs_ops.c
71,7 → 71,8
.dev_handle = dev_handle,
};
 
return vfs_lookup_internal("/", strlen("/"), result, &altroot);
return vfs_lookup_internal("/", strlen("/"), L_DIRECTORY, result,
&altroot);
}
 
void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
195,7 → 196,8
* We already have the root FS.
*/
rwlock_write_lock(&namespace_rwlock);
rc = vfs_lookup_internal(buf, size, &mp_res, NULL);
rc = vfs_lookup_internal(buf, size, L_DIRECTORY, &mp_res,
NULL);
if (rc != EOK) {
/*
* The lookup failed for some reason.
297,12 → 299,16
}
 
/*
* The POSIX interface is open(path, flags, mode).
* We can receive flags and mode along with the VFS_OPEN call; the path
* The POSIX interface is open(path, oflag, mode).
* We can receive oflags and mode along with the VFS_OPEN call; the path
* will need to arrive in another call.
*
* We also receive one private, non-POSIX set of flags called lflag
* used to pass information to vfs_lookup_internal().
*/
int flags = IPC_GET_ARG1(*request);
int mode = IPC_GET_ARG2(*request);
int lflag = IPC_GET_ARG1(*request);
int oflag = IPC_GET_ARG2(*request);
int mode = IPC_GET_ARG3(*request);
size_t len;
 
ipc_callid_t callid;
345,7 → 351,7
* The path is now populated and we can call vfs_lookup_internal().
*/
vfs_lookup_res_t lr;
rc = vfs_lookup_internal(path, len, &lr, NULL);
rc = vfs_lookup_internal(path, len, lflag, &lr, NULL);
if (rc) {
rwlock_read_unlock(&namespace_rwlock);
ipc_answer_0(rid, rc);
/trunk/uspace/srv/vfs/vfs.h
138,6 → 138,9
VFS_TRIPLET;
} vfs_triplet_t;
 
#define L_FILE 1
#define L_DIRECTORY 2
 
typedef struct {
vfs_triplet_t triplet;
size_t size;
203,7 → 206,7
 
extern int fs_name_to_handle(char *, bool);
 
extern int vfs_lookup_internal(char *, size_t, vfs_lookup_res_t *,
extern int vfs_lookup_internal(char *, size_t, int, vfs_lookup_res_t *,
vfs_pair_t *);
 
extern bool vfs_nodes_init(void);
/trunk/uspace/srv/vfs/vfs_lookup.c
55,6 → 55,7
*
* @param path Path to be resolved; it needn't be an ASCIIZ string.
* @param len Number of path characters pointed by path.
* @param lflag Flags to be used during lookup.
* @param result Empty structure where the lookup result will be stored.
* @param altroot If non-empty, will be used instead of rootfs as the root
* of the whole VFS tree.
61,8 → 62,8
*
* @return EOK on success or an error code from errno.h.
*/
int vfs_lookup_internal(char *path, size_t len, vfs_lookup_res_t *result,
vfs_pair_t *altroot)
int vfs_lookup_internal(char *path, size_t len, int lflag,
vfs_lookup_res_t *result, vfs_pair_t *altroot)
{
vfs_pair_t *root;
 
144,9 → 145,9
 
ipc_call_t answer;
int phone = vfs_grab_phone(root->fs_handle);
aid_t req = async_send_3(phone, VFS_LOOKUP, (ipcarg_t) first,
aid_t req = async_send_4(phone, VFS_LOOKUP, (ipcarg_t) first,
(ipcarg_t) (first + len - 1) % PLB_SIZE,
(ipcarg_t) root->dev_handle, &answer);
(ipcarg_t) root->dev_handle, (ipcarg_t) lflag, &answer);
vfs_release_phone(phone);
 
ipcarg_t rc;