Lines Matching defs:fh

60 #define	PRINT_FULL_DATA(fp, func, dfh, fh, name, str)			\
64 if ((fh) != NULL) { \
65 (void) fprintf(fp, ", fh "); \
66 debug_opaque_print(fp, fh, sizeof (*(fh))); \
74 fhandle_t fh;
87 static void fh_print_all_keys(char *fhpath, fhandle_t *fh);
89 static fhlist_ent *fh_lookup(char *fhpath, fhandle_t *fh, fhlist_ent *fhrecp,
97 static fhlist_ent *fh_lookup_link(char *fhpath, fhandle_t *dfh, fhandle_t *fh,
101 static struct export_handle_cache *find_fh_in_export_cache(fhandle_t *fh);
102 static void add_fh_to_export_cache(fhandle_t *fh, char *path);
103 static char *update_export_point(char *fhpath, fhandle_t *fh, char *path);
104 static char *fh_print_absolute(char *fhpath, fhandle_t *fh, char *name);
107 static void nfslog_LOOKUP_calc(fhandle_t *dfh, char *name, fhandle_t *fh,
453 sprint_fid(char *buf, uint_t buflen, const fhandle_t *fh)
463 if (fh->fh_len > NFS_FHMAXDATA)
466 fhlen = fh->fh_len;
470 byte = fh->fh_data[i];
476 fh_print_all_keys(char *fhpath, fhandle_t *fh)
478 if ((fhpath == NULL) || (fh == NULL) || (debug <= 1))
481 db_print_all_keys(fhpath, &fh->fh_fsid, stdout);
485 #define FH_ADD(path, dfh, fh, name) \
486 fh_add(path, dfh, fh, name)
489 * Add the filehandle "fh", which has the name "name" and lives in
495 fh_add(char *fhpath, fhandle_t *dfh, fhandle_t *fh, char *name)
503 PRINT_FULL_DATA(stdout, "fh_add", dfh, fh, name,
508 if (dfh && (memcmp(fh, dfh, NFS_FHSIZE) == 0)) {
513 error = db_add(fhpath, dfh, name, fh, flags);
518 PRINT_FULL_DATA(stdout, "fh_add", dfh, fh, name, "")
520 PRINT_FULL_DATA(stdout, "fh_add", dfh, fh, name, "")
539 * Try to find the filehandle "fh" in the table. Returns 0 and the
547 fh_lookup(char *fhpath, fhandle_t *fh, fhlist_ent *fhrecp, int *errorp)
550 (void) printf("fh_lookup: fh ");
551 debug_opaque_print(stdout, fh, sizeof (*fh));
554 return (db_lookup(fhpath, fh, fhrecp, errorp));
582 * Remove the link entry from the fh table.
591 * Remove the link entry for the file. Remove fh entry if last link.
650 * fh_lookup_link - search the fhtable for the link defined by (dfh,name,fh).
654 * 1. dfh, fh, name are all non-null: Only exact match accepted.
655 * 2. dfh,name non-null, fh null: return first match found.
656 * 3. fh,name non-null, dfh null: return first match found.
657 * 3. fh non-null, dfh, name null: return first match found.
663 fh_lookup_link(char *fhpath, fhandle_t *dfh, fhandle_t *fh, char *name,
671 PRINT_FULL_DATA(stdout, "fh_lookup_link", dfh, fh, name,
678 PRINT_FULL_DATA(stdout, "fh_lookup_link", dfh, fh, name, "")
681 if (fh != NULL) {
682 fhrecp = db_lookup(fhpath, fh, fhrecp, errorp);
685 (void) printf("fh_lookup_link: fh not found\n");
696 PRINT_FULL_DATA(stdout, "fh_lookup_link", dfh, fh,
724 if ((fh != NULL) && fh_compare(fh, &fhrecp->fh)) {
726 PRINT_FULL_DATA(stderr, "fh_lookup_link", dfh, fh,
752 * find_fh_in_export_cache - given an export fh, find it in the cache and
756 find_fh_in_export_cache(fhandle_t *fh)
761 if (memcmp(fh, &p->fh, sizeof (*fh)) == 0)
768 add_fh_to_export_cache(fhandle_t *fh, char *path)
790 (void) memcpy(&new->fh, fh, sizeof (*fh));
796 * update_export_point - called when the path for fh cannot be determined.
809 update_export_point(char *fhpath, fhandle_t *fh, char *path)
813 if ((fh == NULL) || memcmp(&fh->fh_data, &fh->fh_xdata, fh->fh_len)) {
814 /* either null fh or not the root of a shared directory */
818 if ((p = find_fh_in_export_cache(fh)) != NULL) {
822 fh, ((p->name != NULL) ? p->name : ""), "");
840 if ((path = get_export_path(fh, path)) == NULL) {
841 add_fh_to_export_cache(fh, NULL);
846 PRINT_LINK_DATA(stdout, "update_export_point", fh, path, "")
848 if (FH_ADD(fhpath, fh, fh, path)) {
850 add_fh_to_export_cache(fh, path);
860 get_export_path(fhandle_t *fh, char *path)
866 * Return the absolute pathname for the filehandle "fh", using the mapping
869 * (if name is non-null, the function assumes the fh is the parent directory)
876 fh_print_absolute(char *fhpath, fhandle_t *fh, char *name)
900 (void) memcpy((void *) &prevfh, (void *) fh, sizeof (*fh));
901 fh = &prevfh;
904 while ((fhrecp = fh_lookup(fhpath, fh, &fhrec, &error)) != NULL &&
912 if (memcmp(&prevfh, &fhrecp->dfh, sizeof (*fh)) == 0) {
928 assert(fh == &prevfh);
936 fhpath, fh, &parent[strlen(parent) + 1]);
942 len = 2 * (NFS_FHMAXDATA + fh->fh_len); /* fid instead */
955 sprint_fid(str, len, fh);
1016 nfslog_LOOKUP_calc(fhandle_t *dfh, char *name, fhandle_t *fh,
1023 if (fh == &public_fh) {
1025 if (error = FH_ADD(fhpath, fh, fh, name)) {
1042 /* If public fh mclookup, then insert complete path */
1051 if (fh_lookup_link(fhpath, dfh, fh, name, &fhrec, &error) != NULL) {
1058 if (error = FH_ADD(fhpath, dfh, fh, name)) {
1060 "%s: Add fh for '%s' failed: %s\n"), str,
1082 (void) printf("=============\nGETATTR2: fh ");
1102 (void) printf("=============\nSETATTR2: fh ");
1117 * there is no fh to check...
1125 fhandle_t *dfh, *fh;
1131 fh = &res->nfslog_diropres_u.dr_ok.drok_fhandle;
1133 fh = NULL;
1135 dfh, fh, name, "")
1151 fh = NFSLOG_GET_FHANDLE2(&res->nfslog_diropres_u.dr_ok.drok_fhandle);
1152 nfslog_LOOKUP_calc(dfh, name, fh, fhpath, pathp1, pathp2, "Lookup2");
1164 (void) printf("=============\nREADLINK2: fh ");
1184 (void) printf("=============\nREAD2: fh ");
1206 (void) printf("=============\nWRITE2: fh ");
1229 fhandle_t *dfh, *fh;
1236 fh = &res->nfslog_diropres_u.dr_ok.drok_fhandle;
1238 fh = NULL;
1240 dfh, fh, name, "")
1251 /* no returned fh so nothing to add */
1255 fh = NFSLOG_GET_FHANDLE2(&res->nfslog_diropres_u.dr_ok.drok_fhandle);
1256 if (error = FH_ADD(fhpath, dfh, fh, name)) {
1258 "Create2: Add fh for '%s' failed: %s\n"),
1300 * nfsl_RENAME2_fhargs - updates the dfh and name fields for the given fh
1348 * nfslog_LINK2_fhargs - adds link name and fh to fhlist. Note that as a
1349 * result we may have more than one name for an fh.
1357 fhandle_t *dfh, *fh;
1360 fh = &args->la_from;
1365 dfh, fh, name, "")
1370 fh = NFSLOG_GET_FHANDLE2(fh);
1372 *pathp1 = nfslog_get_path(fh, NULL, fhpath, "link2 from");
1377 /* no returned fh so nothing to add */
1381 if (error = FH_ADD(fhpath, dfh, fh, name)) {
1383 "Link2: Add fh for '%s' failed: %s\n"),
1389 * nfslog_SYMLINK2_fhargs - adds symlink name and fh to fhlist if fh returned.
1421 (void) printf("=============\nREADDIR2: fh ");
1442 (void) printf("=============\nSTATFS2: fh ");
1468 (void) printf("=============\nGETATTR3: fh ");
1488 (void) printf("=============\nSETATTR3: fh ");
1503 * there is no fh to check...
1511 fhandle_t *dfh, *fh;
1518 fh = NFSLOG_GET_FHANDLE3(
1521 fh = NULL;
1523 dfh, fh, name, "")
1538 fh = NFSLOG_GET_FHANDLE3(&res->nfslog_LOOKUP3res_u.object);
1539 nfslog_LOOKUP_calc(dfh, name, fh, fhpath, pathp1, pathp2, "Lookup3");
1551 (void) printf("=============\nACCESS3: fh ");
1572 (void) printf("=============\nREADLINK3: fh ");
1592 (void) printf("=============\nREAD3: fh ");
1613 (void) printf("=============\nWRITE3: fh ");
1635 fhandle_t *dfh, *fh;
1643 fh = NFSLOG_GET_FHANDLE3(
1646 fh = NULL;
1648 dfh, fh, name, "")
1659 /* no returned fh so nothing to add */
1663 fh = NFSLOG_GET_FHANDLE3(&res->nfslog_CREATE3res_u.ok.obj.handle);
1664 if (error = FH_ADD(fhpath, dfh, fh, name)) {
1666 "Create3: Add fh for '%s' failed: %s\n"),
1681 fhandle_t *dfh, *fh;
1689 fh = NFSLOG_GET_FHANDLE3(
1692 fh = NULL;
1694 dfh, fh, name, "")
1705 /* no returned fh so nothing to add */
1709 fh = NFSLOG_GET_FHANDLE3(&res->nfslog_MKDIR3res_u.obj.handle);
1710 if (error = FH_ADD(fhpath, dfh, fh, name)) {
1712 "Mkdir3: Add fh for '%s' failed: %s\n"),
1844 fhandle_t *dfh, *fh;
1847 fh = NFSLOG_GET_FHANDLE3(&args->file);
1853 dfh, fh, name, "")
1858 *pathp1 = nfslog_get_path(fh, NULL, fhpath, "link3 from");
1867 if (error = FH_ADD(fhpath, dfh, fh, name)) {
1869 "Link3: Add fh for '%s' failed: %s\n"),
1884 fhandle_t *dfh, *fh;
1892 fh = NFSLOG_GET_FHANDLE3(
1895 fh = NULL;
1897 dfh, fh, name, "")
1907 /* no returned fh so nothing to add */
1911 fh = NFSLOG_GET_FHANDLE3(&res->nfslog_MKNOD3res_u.obj.handle);
1912 if (error = FH_ADD(fhpath, dfh, fh, name)) {
1913 syslog(LOG_ERR, gettext("Mknod3: Add fh for '%s' failed: %s\n"),
1928 fhandle_t *dfh, *fh;
1936 fh = NFSLOG_GET_FHANDLE3(
1939 fh = NULL;
1941 dfh, fh, name, "")
1952 /* no returned fh so nothing to add */
1956 fh = NFSLOG_GET_FHANDLE3(&res->nfslog_SYMLINK3res_u.obj.handle);
1957 if (error = FH_ADD(fhpath, dfh, fh, name)) {
1959 "Symlink3: Add fh for '%s' failed: %s\n"),
1973 (void) printf("=============\nREADDIR3: fh ");
1995 fhandle_t *dfh, *fh;
1999 (void) printf("=============\nREADDIRPLUS3: fh ");
2015 * Loop through the fh/name pair and add them
2024 fh = NFSLOG_GET_FHANDLE3(&ep->name_handle.handle);
2026 nfslog_LOOKUP_calc(dfh, name, fh,
2042 (void) printf("=============\nFSSTAT3: fh ");
2063 (void) printf("=============\nFSINFO3: fh ");
2084 (void) printf("=============\nPATHCONF3: fh ");
2105 (void) printf("=============\nCOMMIT3: fh ");
2130 fhandle_t *fh;
2135 "=============\nSHARE: name '%s', fh ", args->sh_path);
2141 fh = &args->sh_fh_buf;
2149 bcopy(fh->fh_xdata, fh->fh_data, fh->fh_xlen);
2153 fh_print_all_keys(fhpath, fh);
2155 if (fh_lookup_link(fhpath, fh, fh,
2157 if (error = FH_ADD(fhpath, fh, fh, args->sh_path)) {
2159 "Share: Add fh for '%s' failed: %s\n"),
2165 *pathp1 = nfslog_get_path(fh, NULL, fhpath, "share");
2178 fhandle_t *fh;
2182 (void) printf("=============\nUNSHARE: name '%s', fh ",
2189 fh = &args->sh_fh_buf;
2197 bcopy(fh->fh_xdata, fh->fh_data, fh->fh_xlen);
2201 fh_print_all_keys(fhpath, fh);
2204 *pathp1 = nfslog_get_path(fh, NULL, fhpath, "share");
2207 if (error = fh_remove(fhpath, fh, args->sh_path, pathp1)) {
2220 fhandle_t *fh;
2224 (void) printf("=============\nGETFH3: name '%s', fh ",
2231 fh = &args->gfh_fh_buf;
2235 fh_print_all_keys(fhpath, fh);
2237 if (fh_lookup_link(fhpath, fh, fh,
2239 if (error = FH_ADD(fhpath, fh, fh, args->gfh_path)) {
2241 "Getfh: Add fh for '%s' failed: %s\n"),
2247 *pathp1 = nfslog_get_path(fh, NULL, fhpath, "getfh");
2257 * nfslog_get_path - gets the path for this file. fh must be supplied,
2258 * name may be null. If name is supplied, fh is assumed to be a directory
2264 nfslog_get_path(fhandle_t *fh, char *name, char *fhpath, char *prtstr)
2266 char *pathp = fh_print_absolute(fhpath, fh, name);
2269 (void) printf(" %s: path '%s', fh ", prtstr, pathp);
2270 debug_opaque_print(stdout, fh, sizeof (*fh));
2277 * nfslog_process_fh_rec - updates the fh table based on the rpc req