Skip to content

Commit

Permalink
misc/librepo: Fix missing symbol 'flistxattr'
Browse files Browse the repository at this point in the history
flistxattr is a function from Linux's xattr API that isn't
available on FreeBSD and is mapped to FreeBSD syscalls.

flistxattr mapping was missing since some port update.

Reported by:	Rick Miller <vrwmiller@gmail.com>
  • Loading branch information
yurivict committed May 6, 2021
1 parent a166ff3 commit 6d9bd71
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions misc/librepo/Makefile
@@ -1,5 +1,6 @@
PORTNAME= librepo
DISTVERSION= 1.14.0
PORTREVISION= 1
CATEGORIES= misc

MAINTAINER= yuri@FreeBSD.org
Expand Down
21 changes: 21 additions & 0 deletions misc/librepo/files/xattr.c
Expand Up @@ -10,6 +10,16 @@

// code below is adopted and simplified from the 'xattr' python module https://github.com/xattr/xattr/blob/master/xattr/lib_build.c

static void convert_bsd_list(char *namebuf, size_t size) {
size_t offset = 0;
while(offset < size) {
int length = (int) (unsigned char)namebuf[offset];
memmove(namebuf+offset, namebuf+offset+1, length);
namebuf[offset+length] = '\0';
offset += length+1;
}
}

int fsetxattr(int fd, const char *name, const void *value, size_t size, int flags) {
int rv = 0;

Expand All @@ -24,6 +34,17 @@ int fsetxattr(int fd, const char *name, const void *value, size_t size, int flag
return rv;
}

ssize_t flistxattr(int fd, char *namebuf, size_t size) {
ssize_t rv = 0;

rv = extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, namebuf, size);

if (rv > 0 && namebuf)
convert_bsd_list(namebuf, rv);

return rv;
}

ssize_t fgetxattr(int fd, const char *name, void *value, size_t size) {
return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, name, value, size);
}
Expand Down
1 change: 1 addition & 0 deletions misc/librepo/files/xattr.h
@@ -1,4 +1,5 @@

int fsetxattr(int fd, const char *name, const void *value, size_t size, int flags);
ssize_t flistxattr(int fd, char *namebuf, size_t size);
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size);
int fremovexattr(int fd, const char *name);

0 comments on commit 6d9bd71

Please sign in to comment.