nfs4getroot.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
  3. * Written by David Howells (dhowells@redhat.com)
  4. */
  5. #include <linux/nfs_fs.h>
  6. #include "nfs4_fs.h"
  7. #include "internal.h"
  8. #define NFSDBG_FACILITY NFSDBG_CLIENT
  9. int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh, bool auth_probe)
  10. {
  11. struct nfs_fsinfo fsinfo;
  12. int ret = -ENOMEM;
  13. dprintk("--> nfs4_get_rootfh()\n");
  14. fsinfo.fattr = nfs_alloc_fattr();
  15. if (fsinfo.fattr == NULL)
  16. goto out;
  17. /* Start by getting the root filehandle from the server */
  18. ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo, auth_probe);
  19. if (ret < 0) {
  20. dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret);
  21. goto out;
  22. }
  23. if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_TYPE)
  24. || !S_ISDIR(fsinfo.fattr->mode)) {
  25. printk(KERN_ERR "nfs4_get_rootfh:"
  26. " getroot encountered non-directory\n");
  27. ret = -ENOTDIR;
  28. goto out;
  29. }
  30. memcpy(&server->fsid, &fsinfo.fattr->fsid, sizeof(server->fsid));
  31. out:
  32. nfs_free_fattr(fsinfo.fattr);
  33. dprintk("<-- nfs4_get_rootfh() = %d\n", ret);
  34. return ret;
  35. }