static error_t procfs_dir_get_contents (void *hook, char **contents, ssize_t *contents_len) { static const char dot_dotdot[] = ".\0.."; struct procfs_dir_node *dir = hook; const struct procfs_dir_entry *ent; int pos; /* Evaluate how much space is needed. Note that we include the hidden entries, just in case their status changes between now and then. */ pos = sizeof dot_dotdot; for (ent = dir->ops->entries; ent->name; ent++) pos += strlen (ent->name) + 1; *contents = malloc (pos); if (! *contents) return ENOMEM; memcpy (*contents, dot_dotdot, sizeof dot_dotdot); pos = sizeof dot_dotdot; for (ent = dir->ops->entries; ent->name; ent++) { if (! entry_exists (dir, ent)) continue; strcpy (*contents + pos, ent->name); pos += strlen (ent->name) + 1; } *contents_len = pos; return 0; }
//********************************************************** // read a s**t and then check that it's a loader or stack s**t // if expect_stack is true and it's not a stack s**t then reject, and vice versa. //********************************************************** bool SlutTable::read_slut_bc_check_type(GenericPointer slut_location, bool retry, bool expect_stack) { bool result = read_slut_bc(slut_location, retry); if (result) { result = (entry_exists(bluecore::SLUTID_BCCMD_INTERFACE) == expect_stack); if (!result) { invalidate(); } } return result; }