diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2024-05-15 08:49:56 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-05-15 08:49:56 +0200 |
commit | 5a9302bab9c9bb3d1577f04678d074fb7af4115f (patch) | |
tree | 21d04573dfa733e020315d08853c00fc119fb959 /demo/open_by_handle_at.c | |
parent | bdbec30a849807fb5e6841a38cfe0d168e5962b9 (diff) | |
download | seitan-5a9302bab9c9bb3d1577f04678d074fb7af4115f.tar seitan-5a9302bab9c9bb3d1577f04678d074fb7af4115f.tar.gz seitan-5a9302bab9c9bb3d1577f04678d074fb7af4115f.tar.bz2 seitan-5a9302bab9c9bb3d1577f04678d074fb7af4115f.tar.lz seitan-5a9302bab9c9bb3d1577f04678d074fb7af4115f.tar.xz seitan-5a9302bab9c9bb3d1577f04678d074fb7af4115f.tar.zst seitan-5a9302bab9c9bb3d1577f04678d074fb7af4115f.zip |
Add fsetxattr(), fremovexattr(), open_by_handle_at(), and "virtiofsd demo"
Mostly assorted fixes, a new FDGET operation (get a copy of the
target file descriptor via pidfd_getfd()) and a new "FD" flag that
means we have to do that on direct tag reference.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'demo/open_by_handle_at.c')
-rw-r--r-- | demo/open_by_handle_at.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/demo/open_by_handle_at.c b/demo/open_by_handle_at.c new file mode 100644 index 0000000..1f48eca --- /dev/null +++ b/demo/open_by_handle_at.c @@ -0,0 +1,22 @@ +#define _GNU_SOURCE +#include <sys/stat.h> +#include <sys/xattr.h> +#include <fcntl.h> +#include <string.h> +#include <stdio.h> +#include <unistd.h> + +int main(int argc, char **argv) +{ + struct { + struct file_handle f; + unsigned char h[MAX_HANDLE_SZ]; + } handle = { .f.handle_bytes = MAX_HANDLE_SZ }; + int mount_fd, fd; + char buf[BUFSIZ]; + + name_to_handle_at(AT_FDCWD, argv[1], &handle.f, &mount_fd, 0); + fd = open_by_handle_at(mount_fd, &handle.f, 0); + read(fd, buf, BUFSIZ); + fprintf(stdout, "%s", buf); +} |