diff options
-rw-r--r-- | xlators/mount/fuse/src/fuse-helpers.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c index cd35d7192..d0dad29a4 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -134,6 +134,57 @@ get_fuse_state (xlator_t *this, fuse_in_header_t *finh) } +void +frame_fill_groups (call_frame_t *frame) +{ + char filename[128]; + char line[128]; + char *ptr = NULL; + int ret = 0; + FILE *fp = NULL; + int idx = 0; + long int id = 0; + char *saveptr = NULL; + char *endptr = NULL; + + ret = snprintf (filename, 128, "/proc/%d/status", frame->root->pid); + if (ret == 128) + goto out; + + fp = fopen (filename, "r"); + if (!fp) + goto out; + + while ((ptr = fgets (line, 128, fp))) { + if (strncmp (ptr, "Groups:", 7) != 0) + continue; + + ptr = line + 8; + + for (ptr = strtok_r (ptr, " \t\r\n", &saveptr); + ptr; + ptr = strtok_r (NULL, " \t\r\n", &saveptr)) { + errno = 0; + id = strtol (ptr, &endptr, 0); + if (errno == ERANGE) + break; + if (!endptr || *endptr) + break; + frame->root->groups[idx++] = id; + if (idx == GF_REQUEST_MAXGROUPS) + break; + } + + frame->root->ngrps = idx; + break; + } +out: + if (fp) + fclose (fp); + return; +} + + call_frame_t * get_call_frame_for_req (fuse_state_t *state) { @@ -160,6 +211,8 @@ get_call_frame_for_req (fuse_state_t *state) frame->root->unique = finh->unique; } + frame_fill_groups (frame); + if (priv && priv->client_pid_set) frame->root->pid = priv->client_pid; |