16450084aSKeno Fischer /*
26450084aSKeno Fischer * 9p utilities (Linux Implementation)
36450084aSKeno Fischer *
46450084aSKeno Fischer * Copyright IBM, Corp. 2017
56450084aSKeno Fischer *
66450084aSKeno Fischer * Authors:
76450084aSKeno Fischer * Greg Kurz <groug@kaod.org>
86450084aSKeno Fischer *
96450084aSKeno Fischer * This work is licensed under the terms of the GNU GPL, version 2 or later.
106450084aSKeno Fischer * See the COPYING file in the top-level directory.
116450084aSKeno Fischer */
126450084aSKeno Fischer
136450084aSKeno Fischer /*
146450084aSKeno Fischer * Not so fast! You might want to read the 9p developer docs first:
156450084aSKeno Fischer * https://wiki.qemu.org/Documentation/9p
166450084aSKeno Fischer */
176450084aSKeno Fischer
186450084aSKeno Fischer #include "qemu/osdep.h"
196450084aSKeno Fischer #include "qemu/xattr.h"
206450084aSKeno Fischer #include "9p-util.h"
216450084aSKeno Fischer
fgetxattrat_nofollow(int dirfd,const char * filename,const char * name,void * value,size_t size)226450084aSKeno Fischer ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name,
236450084aSKeno Fischer void *value, size_t size)
246450084aSKeno Fischer {
256450084aSKeno Fischer char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
266450084aSKeno Fischer int ret;
276450084aSKeno Fischer
286450084aSKeno Fischer ret = lgetxattr(proc_path, name, value, size);
296450084aSKeno Fischer g_free(proc_path);
306450084aSKeno Fischer return ret;
316450084aSKeno Fischer }
326450084aSKeno Fischer
flistxattrat_nofollow(int dirfd,const char * filename,char * list,size_t size)336450084aSKeno Fischer ssize_t flistxattrat_nofollow(int dirfd, const char *filename,
346450084aSKeno Fischer char *list, size_t size)
356450084aSKeno Fischer {
366450084aSKeno Fischer char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
376450084aSKeno Fischer int ret;
386450084aSKeno Fischer
396450084aSKeno Fischer ret = llistxattr(proc_path, list, size);
406450084aSKeno Fischer g_free(proc_path);
416450084aSKeno Fischer return ret;
426450084aSKeno Fischer }
436450084aSKeno Fischer
fremovexattrat_nofollow(int dirfd,const char * filename,const char * name)446450084aSKeno Fischer ssize_t fremovexattrat_nofollow(int dirfd, const char *filename,
456450084aSKeno Fischer const char *name)
466450084aSKeno Fischer {
476450084aSKeno Fischer char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
486450084aSKeno Fischer int ret;
496450084aSKeno Fischer
506450084aSKeno Fischer ret = lremovexattr(proc_path, name);
516450084aSKeno Fischer g_free(proc_path);
526450084aSKeno Fischer return ret;
536450084aSKeno Fischer }
546450084aSKeno Fischer
fsetxattrat_nofollow(int dirfd,const char * filename,const char * name,void * value,size_t size,int flags)556450084aSKeno Fischer int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name,
566450084aSKeno Fischer void *value, size_t size, int flags)
576450084aSKeno Fischer {
586450084aSKeno Fischer char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
596450084aSKeno Fischer int ret;
606450084aSKeno Fischer
616450084aSKeno Fischer ret = lsetxattr(proc_path, name, value, size, flags);
626450084aSKeno Fischer g_free(proc_path);
636450084aSKeno Fischer return ret;
64*029ed1bdSKeno Fischer
65*029ed1bdSKeno Fischer }
66*029ed1bdSKeno Fischer
qemu_mknodat(int dirfd,const char * filename,mode_t mode,dev_t dev)67*029ed1bdSKeno Fischer int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev)
68*029ed1bdSKeno Fischer {
69*029ed1bdSKeno Fischer return mknodat(dirfd, filename, mode, dev);
706450084aSKeno Fischer }
71