10 #include <linux/errno.h>
11 #include <linux/string.h>
13 #include <linux/slab.h>
14 #include <linux/nfs.h>
15 #include <linux/nfs3.h>
16 #include <linux/nfs_fs.h>
25 #define NFSDBG_FACILITY NFSDBG_PROC
38 }
while (!fatal_signal_pending(
current));
42 #define rpc_call_sync(clnt, msg, flags) nfs3_rpc_wrapper(clnt, msg, flags)
68 dprintk(
"%s: call fsinfo\n", __func__);
71 dprintk(
"%s: reply fsinfo: %d\n", __func__, status);
76 dprintk(
"%s: reply getattr: %d\n", __func__, status);
90 status = do_proc_get_root(server->
client, fhandle, info);
92 status = do_proc_get_root(server->
nfs_client->cl_rpcclient, fhandle, info);
113 dprintk(
"NFS reply getattr: %d\n", status);
140 dprintk(
"NFS reply setattr: %d\n", status);
145 nfs3_proc_lookup(
struct inode *dir,
struct qstr *
name,
179 dprintk(
"NFS reply lookup: %d\n", status);
193 .rpc_cred = entry->
cred,
208 if (mode & MAY_WRITE)
229 nfs_free_fattr(res.
fattr);
231 dprintk(
"NFS reply access: %d\n", status);
235 static int nfs3_proc_readlink(
struct inode *inode,
struct page *
page,
236 unsigned int pgbase,
unsigned int pglen)
251 dprintk(
"NFS call readlink\n");
259 nfs_free_fattr(fattr);
261 dprintk(
"NFS reply readlink: %d\n", status);
285 data->
msg.rpc_argp = &data->
arg;
286 data->
msg.rpc_resp = &data->
res;
287 data->
res.fh = &data->
fh;
296 static int nfs3_do_create(
struct inode *dir,
struct dentry *dentry,
struct nfs3_createdata *data)
316 nfs3_proc_create(
struct inode *dir,
struct dentry *dentry,
struct iattr *sattr,
325 data = nfs3_alloc_createdata();
345 status = nfs3_do_create(dir, dentry, data);
373 dprintk(
"NFS call setattr (post-create)\n");
383 status = nfs3_proc_setattr(dentry, data->
res.fattr, sattr);
385 dprintk(
"NFS reply setattr (post-create): %d\n", status);
391 nfs3_free_createdata(data);
392 dprintk(
"NFS reply create: %d\n", status);
397 nfs3_proc_remove(
struct inode *dir,
struct qstr *name)
420 dprintk(
"NFS reply remove: %d\n", status);
425 nfs3_proc_unlink_setup(
struct rpc_message *msg,
struct inode *dir)
436 nfs3_proc_unlink_done(
struct rpc_task *
task,
struct inode *dir)
439 if (nfs3_async_handle_jukebox(task, dir))
441 res = task->
tk_msg.rpc_resp;
447 nfs3_proc_rename_setup(
struct rpc_message *msg,
struct inode *dir)
458 nfs3_proc_rename_done(
struct rpc_task *task,
struct inode *old_dir,
459 struct inode *new_dir)
463 if (nfs3_async_handle_jukebox(task, old_dir))
465 res = task->
tk_msg.rpc_resp;
473 nfs3_proc_rename(
struct inode *old_dir,
struct qstr *old_name,
474 struct inode *new_dir,
struct qstr *new_name)
477 .old_dir = NFS_FH(old_dir),
479 .new_dir = NFS_FH(new_dir),
503 dprintk(
"NFS reply rename: %d\n", status);
508 nfs3_proc_link(
struct inode *inode,
struct inode *dir,
struct qstr *name)
511 .fromfh = NFS_FH(inode),
513 .toname = name->
name,
527 if (res.fattr ==
NULL || res.dir_attr ==
NULL)
534 nfs_free_fattr(res.dir_attr);
535 nfs_free_fattr(res.fattr);
536 dprintk(
"NFS reply link: %d\n", status);
541 nfs3_proc_symlink(
struct inode *dir,
struct dentry *dentry,
struct page *page,
542 unsigned int len,
struct iattr *sattr)
552 data = nfs3_alloc_createdata();
563 status = nfs3_do_create(dir, dentry, data);
565 nfs3_free_createdata(data);
567 dprintk(
"NFS reply symlink: %d\n", status);
572 nfs3_proc_mkdir(
struct inode *dir,
struct dentry *dentry,
struct iattr *sattr)
582 data = nfs3_alloc_createdata();
592 status = nfs3_do_create(dir, dentry, data);
598 nfs3_free_createdata(data);
599 dprintk(
"NFS reply mkdir: %d\n", status);
604 nfs3_proc_rmdir(
struct inode *dir,
struct qstr *name)
620 if (dir_attr ==
NULL)
626 nfs_free_fattr(dir_attr);
628 dprintk(
"NFS reply rmdir: %d\n", status);
642 nfs3_proc_readdir(
struct dentry *dentry,
struct rpc_cred *
cred,
645 struct inode *dir = dentry->
d_inode;
646 __be32 *verf = NFS_I(dir)->cookieverf;
650 .verf = {verf[0], verf[1]},
670 dprintk(
"NFS call readdir%s %d\n",
671 plus?
"plus" :
"", (
unsigned int) cookie);
684 dprintk(
"NFS reply readdir%s: %d\n",
685 plus?
"plus" :
"", status);
690 nfs3_proc_mknod(
struct inode *dir,
struct dentry *dentry,
struct iattr *sattr,
702 data = nfs3_alloc_createdata();
731 status = nfs3_do_create(dir, dentry, data);
736 nfs3_free_createdata(data);
737 dprintk(
"NFS reply mknod: %d\n", status);
755 dprintk(
"NFS reply fsstat: %d\n", status);
773 dprintk(
"NFS reply fsinfo: %d\n", status);
787 status = do_proc_fsinfo(server->
client, fhandle, info);
789 status = do_proc_fsinfo(server->
nfs_client->cl_rpcclient, fhandle, info);
804 dprintk(
"NFS call pathconf\n");
807 dprintk(
"NFS reply pathconf: %d\n", status);
813 struct inode *inode = data->
header->inode;
815 if (nfs3_async_handle_jukebox(task, inode))
835 struct inode *inode = data->
header->inode;
837 if (nfs3_async_handle_jukebox(task, inode))
861 if (nfs3_async_handle_jukebox(task, data->
inode))
875 struct inode *inode = filp->
f_path.dentry->d_inode;
877 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl);
880 static int nfs3_have_delegation(
struct inode *inode,
fmode_t flags)
885 static int nfs3_return_delegation(
struct inode *inode)
923 .dir_inode_ops = &nfs3_dir_inode_operations,
924 .file_inode_ops = &nfs3_file_inode_operations,
926 .getroot = nfs3_proc_get_root,
929 .getattr = nfs3_proc_getattr,
930 .setattr = nfs3_proc_setattr,
931 .lookup = nfs3_proc_lookup,
932 .access = nfs3_proc_access,
933 .readlink = nfs3_proc_readlink,
934 .create = nfs3_proc_create,
935 .remove = nfs3_proc_remove,
936 .unlink_setup = nfs3_proc_unlink_setup,
937 .unlink_rpc_prepare = nfs3_proc_unlink_rpc_prepare,
938 .unlink_done = nfs3_proc_unlink_done,
939 .rename = nfs3_proc_rename,
940 .rename_setup = nfs3_proc_rename_setup,
941 .rename_rpc_prepare = nfs3_proc_rename_rpc_prepare,
942 .rename_done = nfs3_proc_rename_done,
943 .link = nfs3_proc_link,
944 .symlink = nfs3_proc_symlink,
945 .mkdir = nfs3_proc_mkdir,
946 .rmdir = nfs3_proc_rmdir,
947 .readdir = nfs3_proc_readdir,
948 .mknod = nfs3_proc_mknod,
949 .statfs = nfs3_proc_statfs,
950 .fsinfo = nfs3_proc_fsinfo,
951 .pathconf = nfs3_proc_pathconf,
953 .read_setup = nfs3_proc_read_setup,
955 .read_rpc_prepare = nfs3_proc_read_rpc_prepare,
956 .read_done = nfs3_read_done,
957 .write_setup = nfs3_proc_write_setup,
959 .write_rpc_prepare = nfs3_proc_write_rpc_prepare,
960 .write_done = nfs3_write_done,
961 .commit_setup = nfs3_proc_commit_setup,
962 .commit_rpc_prepare = nfs3_proc_commit_rpc_prepare,
963 .commit_done = nfs3_commit_done,
964 .lock = nfs3_proc_lock,
967 .have_delegation = nfs3_have_delegation,
968 .return_delegation = nfs3_return_delegation,