Skip to content
Snippets Groups Projects
nfs4xdr.c 184 KiB
Newer Older
  • Learn to ignore specific revisions
  • 	{ NFS4ERR_FBIG,		-EFBIG		},
    	{ NFS4ERR_NOSPC,	-ENOSPC		},
    	{ NFS4ERR_ROFS,		-EROFS		},
    	{ NFS4ERR_MLINK,	-EMLINK		},
    	{ NFS4ERR_NAMETOOLONG,	-ENAMETOOLONG	},
    	{ NFS4ERR_NOTEMPTY,	-ENOTEMPTY	},
    	{ NFS4ERR_DQUOT,	-EDQUOT		},
    	{ NFS4ERR_STALE,	-ESTALE		},
    	{ NFS4ERR_BADHANDLE,	-EBADHANDLE	},
    	{ NFS4ERR_BAD_COOKIE,	-EBADCOOKIE	},
    	{ NFS4ERR_NOTSUPP,	-ENOTSUPP	},
    	{ NFS4ERR_TOOSMALL,	-ETOOSMALL	},
    
    	{ NFS4ERR_SERVERFAULT,	-EREMOTEIO	},
    
    	{ NFS4ERR_BADTYPE,	-EBADTYPE	},
    	{ NFS4ERR_LOCKED,	-EAGAIN		},
    	{ NFS4ERR_SYMLINK,	-ELOOP		},
    	{ NFS4ERR_OP_ILLEGAL,	-EOPNOTSUPP	},
    	{ NFS4ERR_DEADLOCK,	-EDEADLK	},
    	{ -1,			-EIO		}
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    };
    
    /*
     * Convert an NFS error code to a local one.
     * This one is used jointly by NFSv2 and NFSv3.
     */
    static int
    
    nfs4_stat_to_errno(int stat)
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    {
    	int i;
    	for (i = 0; nfs_errtbl[i].stat != -1; i++) {
    		if (nfs_errtbl[i].stat == stat)
    			return nfs_errtbl[i].errno;
    	}
    	if (stat <= 10000 || stat > 10100) {
    		/* The server is looney tunes. */
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    	}
    	/* If we cannot translate the error, the recovery routines should
    	 * handle it.
    	 * Note: remaining NFSv4 error codes have values > 10000, so should
    	 * not conflict with native Linux error codes.
    	 */
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    }
    
    #define PROC(proc, argtype, restype)				\
    [NFSPROC4_CLNT_##proc] = {					\
    	.p_proc   = NFSPROC4_COMPOUND,				\
    
    	.p_encode = (kxdreproc_t)nfs4_xdr_##argtype,		\
    
    	.p_decode = (kxdrdproc_t)nfs4_xdr_##restype,		\
    
    	.p_arglen = NFS4_##argtype##_sz,			\
    	.p_replen = NFS4_##restype##_sz,			\
    
    	.p_statidx = NFSPROC4_CLNT_##proc,			\
    	.p_name   = #proc,					\
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    
    struct rpc_procinfo	nfs4_procedures[] = {
    
    	PROC(READ,		enc_read,		dec_read),
    	PROC(WRITE,		enc_write,		dec_write),
    	PROC(COMMIT,		enc_commit,		dec_commit),
    	PROC(OPEN,		enc_open,		dec_open),
    	PROC(OPEN_CONFIRM,	enc_open_confirm,	dec_open_confirm),
    	PROC(OPEN_NOATTR,	enc_open_noattr,	dec_open_noattr),
    	PROC(OPEN_DOWNGRADE,	enc_open_downgrade,	dec_open_downgrade),
    	PROC(CLOSE,		enc_close,		dec_close),
    	PROC(SETATTR,		enc_setattr,		dec_setattr),
    	PROC(FSINFO,		enc_fsinfo,		dec_fsinfo),
    	PROC(RENEW,		enc_renew,		dec_renew),
    	PROC(SETCLIENTID,	enc_setclientid,	dec_setclientid),
    	PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
    	PROC(LOCK,		enc_lock,		dec_lock),
    	PROC(LOCKT,		enc_lockt,		dec_lockt),
    	PROC(LOCKU,		enc_locku,		dec_locku),
    	PROC(ACCESS,		enc_access,		dec_access),
    	PROC(GETATTR,		enc_getattr,		dec_getattr),
    	PROC(LOOKUP,		enc_lookup,		dec_lookup),
    	PROC(LOOKUP_ROOT,	enc_lookup_root,	dec_lookup_root),
    	PROC(REMOVE,		enc_remove,		dec_remove),
    	PROC(RENAME,		enc_rename,		dec_rename),
    	PROC(LINK,		enc_link,		dec_link),
    	PROC(SYMLINK,		enc_symlink,		dec_symlink),
    	PROC(CREATE,		enc_create,		dec_create),
    	PROC(PATHCONF,		enc_pathconf,		dec_pathconf),
    	PROC(STATFS,		enc_statfs,		dec_statfs),
    	PROC(READLINK,		enc_readlink,		dec_readlink),
    	PROC(READDIR,		enc_readdir,		dec_readdir),
    	PROC(SERVER_CAPS,	enc_server_caps,	dec_server_caps),
    	PROC(DELEGRETURN,	enc_delegreturn,	dec_delegreturn),
    	PROC(GETACL,		enc_getacl,		dec_getacl),
    	PROC(SETACL,		enc_setacl,		dec_setacl),
    	PROC(FS_LOCATIONS,	enc_fs_locations,	dec_fs_locations),
    	PROC(RELEASE_LOCKOWNER,	enc_release_lockowner,	dec_release_lockowner),
    
    	PROC(SECINFO,		enc_secinfo,		dec_secinfo),
    
    #if defined(CONFIG_NFS_V4_1)
    
    	PROC(EXCHANGE_ID,	enc_exchange_id,	dec_exchange_id),
    	PROC(CREATE_SESSION,	enc_create_session,	dec_create_session),
    	PROC(DESTROY_SESSION,	enc_destroy_session,	dec_destroy_session),
    	PROC(SEQUENCE,		enc_sequence,		dec_sequence),
    	PROC(GET_LEASE_TIME,	enc_get_lease_time,	dec_get_lease_time),
    	PROC(RECLAIM_COMPLETE,	enc_reclaim_complete,	dec_reclaim_complete),
    	PROC(GETDEVICEINFO,	enc_getdeviceinfo,	dec_getdeviceinfo),
    	PROC(LAYOUTGET,		enc_layoutget,		dec_layoutget),
    
    Andy Adamson's avatar
    Andy Adamson committed
    	PROC(LAYOUTCOMMIT,	enc_layoutcommit,	dec_layoutcommit),
    
    Benny Halevy's avatar
    Benny Halevy committed
    	PROC(LAYOUTRETURN,	enc_layoutreturn,	dec_layoutreturn),
    
    	PROC(SECINFO_NO_NAME,	enc_secinfo_no_name,	dec_secinfo_no_name),
    
    	PROC(TEST_STATEID,	enc_test_stateid,	dec_test_stateid),
    
    	PROC(FREE_STATEID,	enc_free_stateid,	dec_free_stateid),
    
    Andy Adamson's avatar
    Andy Adamson committed
    	PROC(GETDEVICELIST,	enc_getdevicelist,	dec_getdevicelist),
    
    #endif /* CONFIG_NFS_V4_1 */
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    };
    
    struct rpc_version		nfs_version4 = {
    	.number			= 4,
    
    	.nrprocs		= ARRAY_SIZE(nfs4_procedures),
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    	.procs			= nfs4_procedures
    };
    
    /*
     * Local variables:
     *  c-basic-offset: 8
     * End:
     */