/* + * Get fsid from nfs_fh: + * return 0 if *fsid contains a valid value. + */ +int +nlm_fo_get_fsid(struct nfs_fh *fh, int *fsid) +{ + struct nfs_fhbase_new *fh_base = (struct nfs_fhbase_new *) fh->data; + int data_left = fh->size/4; + + nlm_debug_print_fh("nlm_fo_find_fsid", fh); + + /* From fb_version to fb_auth - at least two u32 */ + if (data_left < 2) + return -1; + + /* For various types, check out + * inlcude/linux/nfsd/nfsfsh.h + */ + if ((fh_base->fb_version != 1) || + (fh_base->fb_auth_type != 0) || + (fh_base->fb_fsid_type != 1)) + return -1; + + /* The fb_auth is 0 bytes long - imply fb_auth[0] has + * fsid value. + */ + *fsid = (int) fh_base->fb_auth[0]; + return 0; +}