Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003 * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
0004 * Written by David Howells (dhowells@redhat.com)
0005 */
0006 
0007 #include <linux/nfs_fs.h>
0008 #include "nfs4_fs.h"
0009 #include "internal.h"
0010 
0011 #define NFSDBG_FACILITY     NFSDBG_CLIENT
0012 
0013 int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh, bool auth_probe)
0014 {
0015     struct nfs_fsinfo fsinfo;
0016     int ret = -ENOMEM;
0017 
0018     fsinfo.fattr = nfs_alloc_fattr();
0019     if (fsinfo.fattr == NULL)
0020         goto out;
0021 
0022     /* Start by getting the root filehandle from the server */
0023     ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo, auth_probe);
0024     if (ret < 0) {
0025         dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret);
0026         goto out;
0027     }
0028 
0029     if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_TYPE)
0030             || !S_ISDIR(fsinfo.fattr->mode)) {
0031         printk(KERN_ERR "nfs4_get_rootfh:"
0032                " getroot encountered non-directory\n");
0033         ret = -ENOTDIR;
0034         goto out;
0035     }
0036 
0037     memcpy(&server->fsid, &fsinfo.fattr->fsid, sizeof(server->fsid));
0038 out:
0039     nfs_free_fattr(fsinfo.fattr);
0040     return ret;
0041 }