summaryrefslogtreecommitdiff
path: root/src/shared/memfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/memfd.c')
-rw-r--r--src/shared/memfd.c47
1 files changed, 0 insertions, 47 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;
-}