Merge pull request #366 from giuseppe/use-proc-read-xattrs

direct: use /proc/self/fd to read xattrs
This commit is contained in:
Daniel J Walsh 2022-07-29 15:21:29 -04:00 committed by GitHub
commit f87e1781a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,8 +44,13 @@ static int
direct_listxattr (struct ovl_layer *l, const char *path, char *buf, size_t size) direct_listxattr (struct ovl_layer *l, const char *path, char *buf, size_t size)
{ {
char full_path[PATH_MAX]; char full_path[PATH_MAX];
int ret;
strconcat3 (full_path, PATH_MAX, l->path, "/", path); ret = snprintf (full_path, sizeof (full_path), "/proc/self/fd/%d/%s", l->fd, path);
if (ret >= sizeof (full_path))
{
errno = ENAMETOOLONG;
return -1;
}
return llistxattr (full_path, buf, size); return llistxattr (full_path, buf, size);
} }
@ -54,9 +59,13 @@ static int
direct_getxattr (struct ovl_layer *l, const char *path, const char *name, char *buf, size_t size) direct_getxattr (struct ovl_layer *l, const char *path, const char *name, char *buf, size_t size)
{ {
char full_path[PATH_MAX]; char full_path[PATH_MAX];
int ret;
strconcat3 (full_path, PATH_MAX, l->path, "/", path); ret = snprintf (full_path, sizeof (full_path), "/proc/self/fd/%d/%s", l->fd, path);
if (ret >= sizeof (full_path))
{
errno = ENAMETOOLONG;
return -1;
}
return lgetxattr (full_path, name, buf, size); return lgetxattr (full_path, name, buf, size);
} }