diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/memfd.c | 47 | ||||
-rw-r--r-- | src/shared/memfd.h | 2 |
2 files changed, 0 insertions, 49 deletions
diff --git a/src/shared/memfd.c b/src/shared/memfd.c index f3ce8f84da..b558177951 100644 --- a/src/shared/memfd.c +++ b/src/shared/memfd.c @@ -172,50 +172,3 @@ int memfd_new_and_map(const char *name, size_t sz, void **p) { return r; } - -int memfd_get_name(int fd, char **name) { - char path[sizeof("/proc/self/fd/") + DECIMAL_STR_MAX(int)], buf[FILENAME_MAX+1], *e; - const char *delim, *end; - _cleanup_free_ char *n = NULL; - ssize_t k; - - assert(fd >= 0); - assert(name); - - sprintf(path, "/proc/self/fd/%i", fd); - - k = readlink(path, buf, sizeof(buf)); - if (k < 0) - return -errno; - - if ((size_t) k >= sizeof(buf)) - return -E2BIG; - - buf[k] = 0; - - delim = strstr(buf, ":["); - if (!delim) - return -EIO; - - delim = strchr(delim + 2, ':'); - if (!delim) - return -EIO; - - delim++; - - end = strchr(delim, ']'); - if (!end) - return -EIO; - - n = strndup(delim, end - delim); - if (!n) - return -ENOMEM; - - e = utf8_escape_invalid(n); - if (!e) - return -ENOMEM; - - *name = e; - - return 0; -} diff --git a/src/shared/memfd.h b/src/shared/memfd.h index 8f02b0ff55..cf588fe02f 100644 --- a/src/shared/memfd.h +++ b/src/shared/memfd.h @@ -38,5 +38,3 @@ int memfd_get_sealed(int fd); int memfd_get_size(int fd, uint64_t *sz); int memfd_set_size(int fd, uint64_t sz); - -int memfd_get_name(int fd, char **name); |