bool vfs_valid_handle(struct gsh_buffdesc *desc) { xfs_handle_t *hdl = (xfs_handle_t *) desc->addr; bool fsid_type_ok = false; if ((desc->addr == NULL) || (desc->len != sizeof(xfs_handle_t))) return false; if (isMidDebug(COMPONENT_FSAL)) { char buf[256]; struct display_buffer dspbuf = {sizeof(buf), buf, buf}; display_printf(&dspbuf, "Handle len %d: " " fsid=0x%016"PRIx32".0x%016"PRIx32 " fid_len=%"PRIu16 " fid_pad=%"PRIu16 " fid_gen=%"PRIu32 " fid_ino=%"PRIu64, (int) desc->len, hdl->ha_fsid.val[0], hdl->ha_fsid.val[1], hdl->ha_fid.fid_len, hdl->ha_fid.fid_pad, hdl->ha_fid.fid_gen, hdl->ha_fid.fid_ino); LogMidDebug(COMPONENT_FSAL, "%s", buf); } if (hdl->ha_fid.fid_pad != 0) { switch ((enum fsid_type) (hdl->ha_fid.fid_pad - 1)) { case FSID_NO_TYPE: case FSID_ONE_UINT64: case FSID_MAJOR_64: case FSID_TWO_UINT64: case FSID_TWO_UINT32: case FSID_DEVICE: fsid_type_ok = true; break; } if (!fsid_type_ok) { LogDebug(COMPONENT_FSAL, "FSID Type %02"PRIu16" invalid", hdl->ha_fid.fid_pad - 1); return false; } if (hdl->ha_fid.fid_gen != 0) return false; } return hdl->ha_fid.fid_len == (sizeof(xfs_handle_t) - sizeof(xfs_fsid_t) - sizeof(hdl->ha_fid.fid_len)); }
static bool pseudo_node(char *token, void *arg) { struct node_state *state = (struct node_state *)arg; pseudofs_entry_t *node = NULL; pseudofs_entry_t *new_node = NULL; struct gsh_buffdesc key; char fullpseudopath[MAXPATHLEN + 2]; int j = 0; state->retval = 0; /* start off with no errors */ LogFullDebug(COMPONENT_NFS_V4_PSEUDO, "token %s", token); for (node = state->this_node->sons; node != NULL; node = node->next) { /* Looking for a matching entry */ if (!strcmp(node->name, token)) { /* matched entry is new parent node */ state->this_node = node; return true; } j++; } /* not found so create a new entry */ if (gPseudoFs.last_pseudo_id == (MAX_PSEUDO_ENTRY - 1)) { LogMajor(COMPONENT_NFS_V4_PSEUDO, "Too many nodes in Export_Id %d Path=\"%s\" Pseudo=\"%s\"", state->entry->id, state->entry->fullpath, state->entry->pseudopath); state->retval = ENOMEM; return false; } new_node = gsh_calloc(1, sizeof(pseudofs_entry_t)); if (new_node == NULL) { LogMajor(COMPONENT_NFS_V4_PSEUDO, "Insufficient memory to create pseudo fs node"); state->retval = ENOMEM; return false; } strcpy(new_node->name, token); gPseudoFs.last_pseudo_id++; /** @todo: need to fix this ... */ fullpath(fullpseudopath, new_node, state->this_node, MAXPATHLEN); key = create_pseudo_handle_key(fullpseudopath, (ushort) strlen(fullpseudopath)); new_node->fsopaque = (uint8_t *) key.addr; new_node->pseudo_id = *(uint64_t *) new_node->fsopaque; gPseudoFs.reverse_tab[gPseudoFs.last_pseudo_id] = new_node; new_node->last = new_node; if (isMidDebug(COMPONENT_NFS_V4_PSEUDO)) { char str[256]; sprint_mem(str, new_node->fsopaque, V4_FH_OPAQUE_SIZE); LogMidDebug(COMPONENT_NFS_V4_PSEUDO, "Built pseudofs entry " "index:%u name:%s path:%s handle:%s", gPseudoFs.last_pseudo_id, new_node->name, fullpseudopath, str); } /* Step into the new entry and attach it to the tree */ if (state->this_node->sons == NULL) { state->this_node->sons = new_node; } else { state->this_node->sons->last->next = new_node; state->this_node->sons->last = new_node; } new_node->parent = state->this_node; state->this_node = new_node; return true; }