37 #include <sys/types.h>
46 #define ENOATTR ENODATA
53 int XrdSysFAttr::Del(
const char *Aname,
const char *
Path,
int fd)
59 fd = (fd < 0 ? attropen(
Path,
".", O_RDONLY)
60 : openat( fd,
".", O_RDONLY|O_XATTR));
64 if (fd < 0)
return Diagnose(
"open to remove", Aname,
Path, errno);
68 if (unlinkat(fd, Aname, 0) < 0)
ec = Diagnose(
"remove", Aname,
Path, errno);
80 int XrdSysFAttr::Get(
const char *Aname,
void *Aval,
int Avsz,
81 const char *
Path,
int fd)
87 fd = (fd < 0 ? attropen(
Path, Aname, O_RDONLY)
88 : openat( fd, Aname, O_RDONLY|O_XATTR));
92 if (fd < 0)
return Diagnose(
"open to get", Aname,
Path, errno);
98 if (Avsz) {
if ((
ec =
read(fd, Aval, Avsz)) < 0)
ec = -errno;}
114 #if SOLARIS_VERSION < 11
115 #if !defined(__XOPEN_OR_POSIX)
116 #define dirfd(x) x->dd_fd
118 #define dirfd(x) x->d_fd
122 int XrdSysFAttr::List(AList **aPL,
const char *
Path,
int fd,
int getSz)
133 fd = (fd < 0 ? attropen(
Path,
".", O_RDONLY)
134 : openat( fd,
".", O_RDONLY|O_XATTR));
139 {
if (errno ==
ENOATTR)
return 0;
140 return Diagnose(
"open to list",
"*",
Path, errno);
145 if (!(dP = fdopendir(fd)))
146 {rc = errno;
close(fd);
148 return Diagnose(
"open to list",
"*",
Path, rc);
155 {
if ( (strcmp(
".", dEnt->d_name) && strcmp(
"..", dEnt->d_name))
156 && (aNew = getEnt(
Path, fd, dEnt->d_name, *aPL, 0)))
158 {
if (fstatat(
dirfd(dP), dEnt->d_name, &
Stat, 0))
159 {Diagnose(
"stat", dEnt->d_name,
Path, errno);
continue;}
160 aNew->Vlen =
Stat.st_size;
161 if (maxSz < aNew->Vlen) maxSz = aNew->Vlen;
177 int XrdSysFAttr::Set(
const char *Aname,
const void *Aval,
int Avsz,
178 const char *
Path,
int fd,
int isNew)
180 static const mode_t aMode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH;
181 int oFlag = O_CREAT|O_RDWR|O_TRUNC|O_XATTR | (isNew ? O_EXCL : 0);
186 fd = (fd < 0 ? attropen(
Path, Aname, oFlag, aMode)
187 : openat( fd, Aname, oFlag, aMode));
191 if (fd < 0)
return Diagnose(
"open to set", Aname,
Path, errno);
195 if (
write(fd, Aval, Avsz) < 0)
ec = Diagnose(
"set", Aname,
Path, errno);
int stat(const char *path, struct stat *buf)
struct dirent * readdir(DIR *dirp)
int fstat(int fildes, struct stat *buf)
ssize_t write(int fildes, const void *buf, size_t nbyte)
ssize_t read(int fildes, void *buf, size_t nbyte)