Blame view

fs/nfs/nfs4getroot.c 1011 Bytes
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  // SPDX-License-Identifier: GPL-2.0
a38a9eac7   Bryan Schumaker   NFS: Move the v4 ...
2
3
4
5
6
7
8
  /*
  * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
  */
  
  #include <linux/nfs_fs.h>
  #include "nfs4_fs.h"
d6aa6a81d   Trond Myklebust   NFSv4: fs/nfs/nfs...
9
  #include "internal.h"
a38a9eac7   Bryan Schumaker   NFS: Move the v4 ...
10
11
  
  #define NFSDBG_FACILITY		NFSDBG_CLIENT
5e6b19901   Trond Myklebust   NFSv4: Fix securi...
12
  int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh, bool auth_probe)
a38a9eac7   Bryan Schumaker   NFS: Move the v4 ...
13
14
15
  {
  	struct nfs_fsinfo fsinfo;
  	int ret = -ENOMEM;
a38a9eac7   Bryan Schumaker   NFS: Move the v4 ...
16
17
18
19
20
  	fsinfo.fattr = nfs_alloc_fattr();
  	if (fsinfo.fattr == NULL)
  		goto out;
  
  	/* Start by getting the root filehandle from the server */
5e6b19901   Trond Myklebust   NFSv4: Fix securi...
21
  	ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo, auth_probe);
a38a9eac7   Bryan Schumaker   NFS: Move the v4 ...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  	if (ret < 0) {
  		dprintk("nfs4_get_rootfh: getroot error = %d
  ", -ret);
  		goto out;
  	}
  
  	if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_TYPE)
  			|| !S_ISDIR(fsinfo.fattr->mode)) {
  		printk(KERN_ERR "nfs4_get_rootfh:"
  		       " getroot encountered non-directory
  ");
  		ret = -ENOTDIR;
  		goto out;
  	}
a38a9eac7   Bryan Schumaker   NFS: Move the v4 ...
36
37
38
  	memcpy(&server->fsid, &fsinfo.fattr->fsid, sizeof(server->fsid));
  out:
  	nfs_free_fattr(fsinfo.fattr);
a38a9eac7   Bryan Schumaker   NFS: Move the v4 ...
39
40
  	return ret;
  }