diff options
Diffstat (limited to 'fs/nfsd/nfs4proc.c')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 76 |
1 files changed, 64 insertions, 12 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index c309c881bd4e..eef1629806f5 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -71,11 +71,11 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs | |||
71 | return nfserr_inval; | 71 | return nfserr_inval; |
72 | 72 | ||
73 | if (open->op_share_access & NFS4_SHARE_ACCESS_READ) | 73 | if (open->op_share_access & NFS4_SHARE_ACCESS_READ) |
74 | accmode |= MAY_READ; | 74 | accmode |= NFSD_MAY_READ; |
75 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) | 75 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) |
76 | accmode |= (MAY_WRITE | MAY_TRUNC); | 76 | accmode |= (NFSD_MAY_WRITE | NFSD_MAY_TRUNC); |
77 | if (open->op_share_deny & NFS4_SHARE_DENY_WRITE) | 77 | if (open->op_share_deny & NFS4_SHARE_DENY_WRITE) |
78 | accmode |= MAY_WRITE; | 78 | accmode |= NFSD_MAY_WRITE; |
79 | 79 | ||
80 | status = fh_verify(rqstp, current_fh, S_IFREG, accmode); | 80 | status = fh_verify(rqstp, current_fh, S_IFREG, accmode); |
81 | 81 | ||
@@ -126,7 +126,8 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o | |||
126 | &resfh.fh_handle.fh_base, resfh.fh_handle.fh_size); | 126 | &resfh.fh_handle.fh_base, resfh.fh_handle.fh_size); |
127 | 127 | ||
128 | if (!created) | 128 | if (!created) |
129 | status = do_open_permission(rqstp, current_fh, open, MAY_NOP); | 129 | status = do_open_permission(rqstp, current_fh, open, |
130 | NFSD_MAY_NOP); | ||
130 | 131 | ||
131 | out: | 132 | out: |
132 | fh_put(&resfh); | 133 | fh_put(&resfh); |
@@ -157,7 +158,8 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_ | |||
157 | open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && | 158 | open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && |
158 | (open->op_iattr.ia_size == 0); | 159 | (open->op_iattr.ia_size == 0); |
159 | 160 | ||
160 | status = do_open_permission(rqstp, current_fh, open, MAY_OWNER_OVERRIDE); | 161 | status = do_open_permission(rqstp, current_fh, open, |
162 | NFSD_MAY_OWNER_OVERRIDE); | ||
161 | 163 | ||
162 | return status; | 164 | return status; |
163 | } | 165 | } |
@@ -186,7 +188,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
186 | cstate->current_fh.fh_handle.fh_size = rp->rp_openfh_len; | 188 | cstate->current_fh.fh_handle.fh_size = rp->rp_openfh_len; |
187 | memcpy(&cstate->current_fh.fh_handle.fh_base, rp->rp_openfh, | 189 | memcpy(&cstate->current_fh.fh_handle.fh_base, rp->rp_openfh, |
188 | rp->rp_openfh_len); | 190 | rp->rp_openfh_len); |
189 | status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP); | 191 | status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); |
190 | if (status) | 192 | if (status) |
191 | dprintk("nfsd4_open: replay failed" | 193 | dprintk("nfsd4_open: replay failed" |
192 | " restoring previous filehandle\n"); | 194 | " restoring previous filehandle\n"); |
@@ -285,7 +287,7 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
285 | cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; | 287 | cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; |
286 | memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval, | 288 | memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval, |
287 | putfh->pf_fhlen); | 289 | putfh->pf_fhlen); |
288 | return fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP); | 290 | return fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); |
289 | } | 291 | } |
290 | 292 | ||
291 | static __be32 | 293 | static __be32 |
@@ -363,7 +365,8 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
363 | 365 | ||
364 | fh_init(&resfh, NFS4_FHSIZE); | 366 | fh_init(&resfh, NFS4_FHSIZE); |
365 | 367 | ||
366 | status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, MAY_CREATE); | 368 | status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, |
369 | NFSD_MAY_CREATE); | ||
367 | if (status == nfserr_symlink) | 370 | if (status == nfserr_symlink) |
368 | status = nfserr_notdir; | 371 | status = nfserr_notdir; |
369 | if (status) | 372 | if (status) |
@@ -445,7 +448,7 @@ nfsd4_getattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
445 | { | 448 | { |
446 | __be32 status; | 449 | __be32 status; |
447 | 450 | ||
448 | status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP); | 451 | status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); |
449 | if (status) | 452 | if (status) |
450 | return status; | 453 | return status; |
451 | 454 | ||
@@ -730,7 +733,7 @@ _nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
730 | int count; | 733 | int count; |
731 | __be32 status; | 734 | __be32 status; |
732 | 735 | ||
733 | status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP); | 736 | status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); |
734 | if (status) | 737 | if (status) |
735 | return status; | 738 | return status; |
736 | 739 | ||
@@ -843,10 +846,13 @@ struct nfsd4_operation { | |||
843 | #define ALLOWED_WITHOUT_FH 1 | 846 | #define ALLOWED_WITHOUT_FH 1 |
844 | /* GETATTR and ops not listed as returning NFS4ERR_MOVED: */ | 847 | /* GETATTR and ops not listed as returning NFS4ERR_MOVED: */ |
845 | #define ALLOWED_ON_ABSENT_FS 2 | 848 | #define ALLOWED_ON_ABSENT_FS 2 |
849 | char *op_name; | ||
846 | }; | 850 | }; |
847 | 851 | ||
848 | static struct nfsd4_operation nfsd4_ops[]; | 852 | static struct nfsd4_operation nfsd4_ops[]; |
849 | 853 | ||
854 | static inline char *nfsd4_op_name(unsigned opnum); | ||
855 | |||
850 | /* | 856 | /* |
851 | * COMPOUND call. | 857 | * COMPOUND call. |
852 | */ | 858 | */ |
@@ -888,7 +894,9 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
888 | while (!status && resp->opcnt < args->opcnt) { | 894 | while (!status && resp->opcnt < args->opcnt) { |
889 | op = &args->ops[resp->opcnt++]; | 895 | op = &args->ops[resp->opcnt++]; |
890 | 896 | ||
891 | dprintk("nfsv4 compound op #%d: %d\n", resp->opcnt, op->opnum); | 897 | dprintk("nfsv4 compound op #%d/%d: %d (%s)\n", |
898 | resp->opcnt, args->opcnt, op->opnum, | ||
899 | nfsd4_op_name(op->opnum)); | ||
892 | 900 | ||
893 | /* | 901 | /* |
894 | * The XDR decode routines may have pre-set op->status; | 902 | * The XDR decode routines may have pre-set op->status; |
@@ -952,126 +960,170 @@ encode_op: | |||
952 | out: | 960 | out: |
953 | nfsd4_release_compoundargs(args); | 961 | nfsd4_release_compoundargs(args); |
954 | cstate_free(cstate); | 962 | cstate_free(cstate); |
963 | dprintk("nfsv4 compound returned %d\n", ntohl(status)); | ||
955 | return status; | 964 | return status; |
956 | } | 965 | } |
957 | 966 | ||
958 | static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = { | 967 | static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = { |
959 | [OP_ACCESS] = { | 968 | [OP_ACCESS] = { |
960 | .op_func = (nfsd4op_func)nfsd4_access, | 969 | .op_func = (nfsd4op_func)nfsd4_access, |
970 | .op_name = "OP_ACCESS", | ||
961 | }, | 971 | }, |
962 | [OP_CLOSE] = { | 972 | [OP_CLOSE] = { |
963 | .op_func = (nfsd4op_func)nfsd4_close, | 973 | .op_func = (nfsd4op_func)nfsd4_close, |
974 | .op_name = "OP_CLOSE", | ||
964 | }, | 975 | }, |
965 | [OP_COMMIT] = { | 976 | [OP_COMMIT] = { |
966 | .op_func = (nfsd4op_func)nfsd4_commit, | 977 | .op_func = (nfsd4op_func)nfsd4_commit, |
978 | .op_name = "OP_COMMIT", | ||
967 | }, | 979 | }, |
968 | [OP_CREATE] = { | 980 | [OP_CREATE] = { |
969 | .op_func = (nfsd4op_func)nfsd4_create, | 981 | .op_func = (nfsd4op_func)nfsd4_create, |
982 | .op_name = "OP_CREATE", | ||
970 | }, | 983 | }, |
971 | [OP_DELEGRETURN] = { | 984 | [OP_DELEGRETURN] = { |
972 | .op_func = (nfsd4op_func)nfsd4_delegreturn, | 985 | .op_func = (nfsd4op_func)nfsd4_delegreturn, |
986 | .op_name = "OP_DELEGRETURN", | ||
973 | }, | 987 | }, |
974 | [OP_GETATTR] = { | 988 | [OP_GETATTR] = { |
975 | .op_func = (nfsd4op_func)nfsd4_getattr, | 989 | .op_func = (nfsd4op_func)nfsd4_getattr, |
976 | .op_flags = ALLOWED_ON_ABSENT_FS, | 990 | .op_flags = ALLOWED_ON_ABSENT_FS, |
991 | .op_name = "OP_GETATTR", | ||
977 | }, | 992 | }, |
978 | [OP_GETFH] = { | 993 | [OP_GETFH] = { |
979 | .op_func = (nfsd4op_func)nfsd4_getfh, | 994 | .op_func = (nfsd4op_func)nfsd4_getfh, |
995 | .op_name = "OP_GETFH", | ||
980 | }, | 996 | }, |
981 | [OP_LINK] = { | 997 | [OP_LINK] = { |
982 | .op_func = (nfsd4op_func)nfsd4_link, | 998 | .op_func = (nfsd4op_func)nfsd4_link, |
999 | .op_name = "OP_LINK", | ||
983 | }, | 1000 | }, |
984 | [OP_LOCK] = { | 1001 | [OP_LOCK] = { |
985 | .op_func = (nfsd4op_func)nfsd4_lock, | 1002 | .op_func = (nfsd4op_func)nfsd4_lock, |
1003 | .op_name = "OP_LOCK", | ||
986 | }, | 1004 | }, |
987 | [OP_LOCKT] = { | 1005 | [OP_LOCKT] = { |
988 | .op_func = (nfsd4op_func)nfsd4_lockt, | 1006 | .op_func = (nfsd4op_func)nfsd4_lockt, |
1007 | .op_name = "OP_LOCKT", | ||
989 | }, | 1008 | }, |
990 | [OP_LOCKU] = { | 1009 | [OP_LOCKU] = { |
991 | .op_func = (nfsd4op_func)nfsd4_locku, | 1010 | .op_func = (nfsd4op_func)nfsd4_locku, |
1011 | .op_name = "OP_LOCKU", | ||
992 | }, | 1012 | }, |
993 | [OP_LOOKUP] = { | 1013 | [OP_LOOKUP] = { |
994 | .op_func = (nfsd4op_func)nfsd4_lookup, | 1014 | .op_func = (nfsd4op_func)nfsd4_lookup, |
1015 | .op_name = "OP_LOOKUP", | ||
995 | }, | 1016 | }, |
996 | [OP_LOOKUPP] = { | 1017 | [OP_LOOKUPP] = { |
997 | .op_func = (nfsd4op_func)nfsd4_lookupp, | 1018 | .op_func = (nfsd4op_func)nfsd4_lookupp, |
1019 | .op_name = "OP_LOOKUPP", | ||
998 | }, | 1020 | }, |
999 | [OP_NVERIFY] = { | 1021 | [OP_NVERIFY] = { |
1000 | .op_func = (nfsd4op_func)nfsd4_nverify, | 1022 | .op_func = (nfsd4op_func)nfsd4_nverify, |
1023 | .op_name = "OP_NVERIFY", | ||
1001 | }, | 1024 | }, |
1002 | [OP_OPEN] = { | 1025 | [OP_OPEN] = { |
1003 | .op_func = (nfsd4op_func)nfsd4_open, | 1026 | .op_func = (nfsd4op_func)nfsd4_open, |
1027 | .op_name = "OP_OPEN", | ||
1004 | }, | 1028 | }, |
1005 | [OP_OPEN_CONFIRM] = { | 1029 | [OP_OPEN_CONFIRM] = { |
1006 | .op_func = (nfsd4op_func)nfsd4_open_confirm, | 1030 | .op_func = (nfsd4op_func)nfsd4_open_confirm, |
1031 | .op_name = "OP_OPEN_CONFIRM", | ||
1007 | }, | 1032 | }, |
1008 | [OP_OPEN_DOWNGRADE] = { | 1033 | [OP_OPEN_DOWNGRADE] = { |
1009 | .op_func = (nfsd4op_func)nfsd4_open_downgrade, | 1034 | .op_func = (nfsd4op_func)nfsd4_open_downgrade, |
1035 | .op_name = "OP_OPEN_DOWNGRADE", | ||
1010 | }, | 1036 | }, |
1011 | [OP_PUTFH] = { | 1037 | [OP_PUTFH] = { |
1012 | .op_func = (nfsd4op_func)nfsd4_putfh, | 1038 | .op_func = (nfsd4op_func)nfsd4_putfh, |
1013 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1039 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1040 | .op_name = "OP_PUTFH", | ||
1014 | }, | 1041 | }, |
1015 | [OP_PUTPUBFH] = { | 1042 | [OP_PUTPUBFH] = { |
1016 | /* unsupported; just for future reference: */ | 1043 | /* unsupported, just for future reference: */ |
1017 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1044 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1045 | .op_name = "OP_PUTPUBFH", | ||
1018 | }, | 1046 | }, |
1019 | [OP_PUTROOTFH] = { | 1047 | [OP_PUTROOTFH] = { |
1020 | .op_func = (nfsd4op_func)nfsd4_putrootfh, | 1048 | .op_func = (nfsd4op_func)nfsd4_putrootfh, |
1021 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1049 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1050 | .op_name = "OP_PUTROOTFH", | ||
1022 | }, | 1051 | }, |
1023 | [OP_READ] = { | 1052 | [OP_READ] = { |
1024 | .op_func = (nfsd4op_func)nfsd4_read, | 1053 | .op_func = (nfsd4op_func)nfsd4_read, |
1054 | .op_name = "OP_READ", | ||
1025 | }, | 1055 | }, |
1026 | [OP_READDIR] = { | 1056 | [OP_READDIR] = { |
1027 | .op_func = (nfsd4op_func)nfsd4_readdir, | 1057 | .op_func = (nfsd4op_func)nfsd4_readdir, |
1058 | .op_name = "OP_READDIR", | ||
1028 | }, | 1059 | }, |
1029 | [OP_READLINK] = { | 1060 | [OP_READLINK] = { |
1030 | .op_func = (nfsd4op_func)nfsd4_readlink, | 1061 | .op_func = (nfsd4op_func)nfsd4_readlink, |
1062 | .op_name = "OP_READLINK", | ||
1031 | }, | 1063 | }, |
1032 | [OP_REMOVE] = { | 1064 | [OP_REMOVE] = { |
1033 | .op_func = (nfsd4op_func)nfsd4_remove, | 1065 | .op_func = (nfsd4op_func)nfsd4_remove, |
1066 | .op_name = "OP_REMOVE", | ||
1034 | }, | 1067 | }, |
1035 | [OP_RENAME] = { | 1068 | [OP_RENAME] = { |
1069 | .op_name = "OP_RENAME", | ||
1036 | .op_func = (nfsd4op_func)nfsd4_rename, | 1070 | .op_func = (nfsd4op_func)nfsd4_rename, |
1037 | }, | 1071 | }, |
1038 | [OP_RENEW] = { | 1072 | [OP_RENEW] = { |
1039 | .op_func = (nfsd4op_func)nfsd4_renew, | 1073 | .op_func = (nfsd4op_func)nfsd4_renew, |
1040 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1074 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1075 | .op_name = "OP_RENEW", | ||
1041 | }, | 1076 | }, |
1042 | [OP_RESTOREFH] = { | 1077 | [OP_RESTOREFH] = { |
1043 | .op_func = (nfsd4op_func)nfsd4_restorefh, | 1078 | .op_func = (nfsd4op_func)nfsd4_restorefh, |
1044 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1079 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1080 | .op_name = "OP_RESTOREFH", | ||
1045 | }, | 1081 | }, |
1046 | [OP_SAVEFH] = { | 1082 | [OP_SAVEFH] = { |
1047 | .op_func = (nfsd4op_func)nfsd4_savefh, | 1083 | .op_func = (nfsd4op_func)nfsd4_savefh, |
1084 | .op_name = "OP_SAVEFH", | ||
1048 | }, | 1085 | }, |
1049 | [OP_SECINFO] = { | 1086 | [OP_SECINFO] = { |
1050 | .op_func = (nfsd4op_func)nfsd4_secinfo, | 1087 | .op_func = (nfsd4op_func)nfsd4_secinfo, |
1088 | .op_name = "OP_SECINFO", | ||
1051 | }, | 1089 | }, |
1052 | [OP_SETATTR] = { | 1090 | [OP_SETATTR] = { |
1053 | .op_func = (nfsd4op_func)nfsd4_setattr, | 1091 | .op_func = (nfsd4op_func)nfsd4_setattr, |
1092 | .op_name = "OP_SETATTR", | ||
1054 | }, | 1093 | }, |
1055 | [OP_SETCLIENTID] = { | 1094 | [OP_SETCLIENTID] = { |
1056 | .op_func = (nfsd4op_func)nfsd4_setclientid, | 1095 | .op_func = (nfsd4op_func)nfsd4_setclientid, |
1057 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1096 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1097 | .op_name = "OP_SETCLIENTID", | ||
1058 | }, | 1098 | }, |
1059 | [OP_SETCLIENTID_CONFIRM] = { | 1099 | [OP_SETCLIENTID_CONFIRM] = { |
1060 | .op_func = (nfsd4op_func)nfsd4_setclientid_confirm, | 1100 | .op_func = (nfsd4op_func)nfsd4_setclientid_confirm, |
1061 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1101 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1102 | .op_name = "OP_SETCLIENTID_CONFIRM", | ||
1062 | }, | 1103 | }, |
1063 | [OP_VERIFY] = { | 1104 | [OP_VERIFY] = { |
1064 | .op_func = (nfsd4op_func)nfsd4_verify, | 1105 | .op_func = (nfsd4op_func)nfsd4_verify, |
1106 | .op_name = "OP_VERIFY", | ||
1065 | }, | 1107 | }, |
1066 | [OP_WRITE] = { | 1108 | [OP_WRITE] = { |
1067 | .op_func = (nfsd4op_func)nfsd4_write, | 1109 | .op_func = (nfsd4op_func)nfsd4_write, |
1110 | .op_name = "OP_WRITE", | ||
1068 | }, | 1111 | }, |
1069 | [OP_RELEASE_LOCKOWNER] = { | 1112 | [OP_RELEASE_LOCKOWNER] = { |
1070 | .op_func = (nfsd4op_func)nfsd4_release_lockowner, | 1113 | .op_func = (nfsd4op_func)nfsd4_release_lockowner, |
1071 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1114 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1115 | .op_name = "OP_RELEASE_LOCKOWNER", | ||
1072 | }, | 1116 | }, |
1073 | }; | 1117 | }; |
1074 | 1118 | ||
1119 | static inline char * | ||
1120 | nfsd4_op_name(unsigned opnum) | ||
1121 | { | ||
1122 | if (opnum < ARRAY_SIZE(nfsd4_ops)) | ||
1123 | return nfsd4_ops[opnum].op_name; | ||
1124 | return "unknown_operation"; | ||
1125 | } | ||
1126 | |||
1075 | #define nfs4svc_decode_voidargs NULL | 1127 | #define nfs4svc_decode_voidargs NULL |
1076 | #define nfs4svc_release_void NULL | 1128 | #define nfs4svc_release_void NULL |
1077 | #define nfsd4_voidres nfsd4_voidargs | 1129 | #define nfsd4_voidres nfsd4_voidargs |