nfs_open2(): Add a new nfs_open2() function that takes a mode argument.
Pass mode all the way down to nfs*_open_async() but we do not yet have any plumbing to actually use it. That will come later as we implement O_CREAT support. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>libnfs-4.0.0-vitalif
parent
8c59fe7f24
commit
0ce4917afd
|
@ -436,7 +436,7 @@ int nfs3_mknod_async(struct nfs_context *nfs, const char *path, int mode,
|
|||
int nfs3_mount_async(struct nfs_context *nfs, const char *server,
|
||||
const char *export, nfs_cb cb, void *private_data);
|
||||
int nfs3_open_async(struct nfs_context *nfs, const char *path, int flags,
|
||||
nfs_cb cb, void *private_data);
|
||||
int mode, nfs_cb cb, void *private_data);
|
||||
int nfs3_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb,
|
||||
void *private_data);
|
||||
int nfs3_pread_async_internal(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
||||
|
@ -483,7 +483,7 @@ int nfs4_mkdir2_async(struct nfs_context *nfs, const char *path, int mode,
|
|||
int nfs4_mount_async(struct nfs_context *nfs, const char *server,
|
||||
const char *export, nfs_cb cb, void *private_data);
|
||||
int nfs4_open_async(struct nfs_context *nfs, const char *path, int flags,
|
||||
nfs_cb cb, void *private_data);
|
||||
int mode, nfs_cb cb, void *private_data);
|
||||
int nfs4_pread_async_internal(struct nfs_context *nfs, struct nfsfh *nfsfh,
|
||||
uint64_t offset, size_t count, nfs_cb cb,
|
||||
void *private_data, int update_pos);
|
||||
|
|
|
@ -537,6 +537,8 @@ EXTERN uint16_t nfs_umask(struct nfs_context *nfs, uint16_t mask);
|
|||
*/
|
||||
EXTERN int nfs_open_async(struct nfs_context *nfs, const char *path, int flags,
|
||||
nfs_cb cb, void *private_data);
|
||||
EXTERN int nfs_open2_async(struct nfs_context *nfs, const char *path, int flags,
|
||||
int mode, nfs_cb cb, void *private_data);
|
||||
/*
|
||||
* Sync open(<filename>)
|
||||
* Function returns
|
||||
|
@ -545,6 +547,8 @@ EXTERN int nfs_open_async(struct nfs_context *nfs, const char *path, int flags,
|
|||
*/
|
||||
EXTERN int nfs_open(struct nfs_context *nfs, const char *path, int flags,
|
||||
struct nfsfh **nfsfh);
|
||||
EXTERN int nfs_open2(struct nfs_context *nfs, const char *path, int flags,
|
||||
int mode, struct nfsfh **nfsfh);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -370,6 +370,26 @@ nfs_open(struct nfs_context *nfs, const char *path, int flags,
|
|||
return cb_data.status;
|
||||
}
|
||||
|
||||
int
|
||||
nfs_open2(struct nfs_context *nfs, const char *path, int flags,
|
||||
int mode, struct nfsfh **nfsfh)
|
||||
{
|
||||
struct sync_cb_data cb_data;
|
||||
|
||||
cb_data.is_finished = 0;
|
||||
cb_data.return_data = nfsfh;
|
||||
|
||||
if (nfs_open2_async(nfs, path, flags, mode, open_cb, &cb_data) != 0) {
|
||||
nfs_set_error(nfs, "nfs_open2_async failed. %s",
|
||||
nfs_get_error(nfs));
|
||||
return -1;
|
||||
}
|
||||
|
||||
wait_for_nfs_reply(nfs, &cb_data);
|
||||
|
||||
return cb_data.status;
|
||||
}
|
||||
|
||||
/*
|
||||
* chdir()
|
||||
*/
|
||||
|
|
|
@ -49,6 +49,8 @@ nfs_mount
|
|||
nfs_mount_async
|
||||
nfs_open
|
||||
nfs_open_async
|
||||
nfs_open2
|
||||
nfs_open2_async
|
||||
nfs_opendir
|
||||
nfs_opendir_async
|
||||
nfs_parse_url_full
|
||||
|
|
17
lib/libnfs.c
17
lib/libnfs.c
|
@ -952,14 +952,16 @@ nfs_lstat64_async(struct nfs_context *nfs, const char *path,
|
|||
}
|
||||
|
||||
int
|
||||
nfs_open_async(struct nfs_context *nfs, const char *path, int flags,
|
||||
nfs_cb cb, void *private_data)
|
||||
nfs_open2_async(struct nfs_context *nfs, const char *path, int flags,
|
||||
int mode, nfs_cb cb, void *private_data)
|
||||
{
|
||||
switch (nfs->version) {
|
||||
case NFS_V3:
|
||||
return nfs3_open_async(nfs, path, flags, cb, private_data);
|
||||
return nfs3_open_async(nfs, path, flags, mode,
|
||||
cb, private_data);
|
||||
case NFS_V4:
|
||||
return nfs4_open_async(nfs, path, flags, cb, private_data);
|
||||
return nfs4_open_async(nfs, path, flags, mode,
|
||||
cb, private_data);
|
||||
default:
|
||||
nfs_set_error(nfs, "%s does not support NFSv%d",
|
||||
__FUNCTION__, nfs->version);
|
||||
|
@ -967,6 +969,13 @@ nfs_open_async(struct nfs_context *nfs, const char *path, int flags,
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
nfs_open_async(struct nfs_context *nfs, const char *path, int flags,
|
||||
nfs_cb cb, void *private_data)
|
||||
{
|
||||
return nfs_open2_async(nfs, path, flags, 0, cb, private_data);
|
||||
}
|
||||
|
||||
int
|
||||
nfs_chdir_async(struct nfs_context *nfs, const char *path,
|
||||
nfs_cb cb, void *private_data)
|
||||
|
|
|
@ -4910,9 +4910,10 @@ nfs3_open_continue_internal(struct nfs_context *nfs,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* TODO add the plumbing for mode */
|
||||
int
|
||||
nfs3_open_async(struct nfs_context *nfs, const char *path, int flags,
|
||||
nfs_cb cb, void *private_data)
|
||||
int mode, nfs_cb cb, void *private_data)
|
||||
{
|
||||
if (nfs3_lookuppath_async(nfs, path, 0, cb, private_data,
|
||||
nfs3_open_continue_internal,
|
||||
|
|
|
@ -1648,7 +1648,7 @@ nfs4_open_readlink_cb(struct rpc_context *rpc, int status, void *command_data,
|
|||
* Try to call open again.
|
||||
*/
|
||||
if (nfs4_open_async(nfs, path, data->filler.flags,
|
||||
data->cb, data->private_data) < 0) {
|
||||
0, data->cb, data->private_data) < 0) {
|
||||
data->cb(-ENOMEM, nfs, nfs_get_error(nfs), data->private_data);
|
||||
free_nfs4_cb_data(data);
|
||||
free(path);
|
||||
|
@ -1777,9 +1777,10 @@ nfs4_populate_open(struct nfs4_cb_data *data, nfs_argop4 *op)
|
|||
return 3;
|
||||
}
|
||||
|
||||
/* TODO add the plumbing for mode */
|
||||
int
|
||||
nfs4_open_async(struct nfs_context *nfs, const char *orig_path, int flags,
|
||||
nfs_cb cb, void *private_data)
|
||||
int mode, nfs_cb cb, void *private_data)
|
||||
{
|
||||
struct nfs4_cb_data *data;
|
||||
char *path;
|
||||
|
|
Loading…
Reference in New Issue