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;
-}
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);