nfs4getroot.c 975 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. fsinfo.fattr = nfs_alloc_fattr();
  14. if (fsinfo.fattr == NULL)
  15. goto out;
  16. /* Start by getting the root filehandle from the server */
  17. ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo, auth_probe);
  18. if (ret < 0) {
  19. dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret);
  20. goto out;
  21. }
  22. if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_TYPE)
  23. || !S_ISDIR(fsinfo.fattr->mode)) {
  24. printk(KERN_ERR "nfs4_get_rootfh:"
  25. " getroot encountered non-directory\n");
  26. ret = -ENOTDIR;
  27. goto out;
  28. }
  29. memcpy(&server->fsid, &fsinfo.fattr->fsid, sizeof(server->fsid));
  30. out:
  31. nfs_free_fattr(fsinfo.fattr);
  32. return ret;
  33. }