Changeset View
Changeset View
Standalone View
Standalone View
lib/libcasper/services/cap_fileargs/cap_fileargs.c
Show First 20 Lines • Show All 494 Lines • ▼ Show 20 Lines | if (caprightsp != NULL) { | ||||
} | } | ||||
} | } | ||||
return (fd); | return (fd); | ||||
} | } | ||||
static void | static void | ||||
fileargs_add_cache(nvlist_t *nvlout, const nvlist_t *limits, | fileargs_add_cache(nvlist_t *nvlout, const nvlist_t *limits, | ||||
const char *curent_name) | const char *current_name) | ||||
{ | { | ||||
int type, i, fd; | int type, i, fd; | ||||
void *cookie; | void *cookie; | ||||
nvlist_t *new; | nvlist_t *new; | ||||
const char *fname; | const char *fname; | ||||
struct stat sb; | struct stat sb; | ||||
if ((capflags & O_CREAT) != 0) { | if ((capflags & O_CREAT) != 0) { | ||||
Show All 10 Lines | if (fname == NULL) { | ||||
allcached = true; | allcached = true; | ||||
return; | return; | ||||
} | } | ||||
/* We doing that to catch next element name. */ | /* We doing that to catch next element name. */ | ||||
if (i == CACHE_SIZE) { | if (i == CACHE_SIZE) { | ||||
break; | break; | ||||
} | } | ||||
if (type != NV_TYPE_NULL || | if (type != NV_TYPE_NULL || (current_name != NULL && | ||||
(curent_name != NULL && strcmp(fname, curent_name) == 0)) { | strcmp(fname, current_name) == 0)) { | ||||
curent_name = NULL; | current_name = NULL; | ||||
i--; | i--; | ||||
continue; | continue; | ||||
} | } | ||||
new = nvlist_create(NV_FLAG_NO_UNIQUE); | new = nvlist_create(NV_FLAG_NO_UNIQUE); | ||||
if ((allowed_operations & FA_OPEN) != 0) { | if ((allowed_operations & FA_OPEN) != 0) { | ||||
fd = open_file(fname); | fd = open_file(fname); | ||||
if (fd < 0) { | if (fd < 0) { | ||||
i--; | i--; | ||||
nvlist_destroy(new); | nvlist_destroy(new); | ||||
continue; | continue; | ||||
} | } | ||||
nvlist_move_descriptor(new, "fd", fd); | nvlist_move_descriptor(new, "fd", fd); | ||||
} | } | ||||
if ((allowed_operations & FA_LSTAT) != 0) { | if ((allowed_operations & FA_LSTAT) != 0) { | ||||
if (lstat(fname, &sb) < 0) { | if (lstat(fname, &sb) < 0) { | ||||
i--; | i--; | ||||
nvlist_destroy(new); | nvlist_destroy(new); | ||||
continue; | continue; | ||||
} | } | ||||
nvlist_add_binary(new, "stat", &sb, sizeof(sb)); | nvlist_add_binary(new, "stat", &sb, sizeof(sb)); | ||||
} | } | ||||
nvlist_add_nvlist(nvlout, fname, new); | nvlist_move_nvlist(nvlout, fname, new); | ||||
} | } | ||||
cacheposition = cookie; | cacheposition = cookie; | ||||
lastname = fname; | lastname = fname; | ||||
} | } | ||||
static bool | static bool | ||||
fileargs_allowed(const nvlist_t *limits, const nvlist_t *request, int operation) | fileargs_allowed(const nvlist_t *limits, const nvlist_t *request, int operation) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |