return "unknown";
}
-static int project_get_xattr(const char *pathname, struct fsxattr *fsx)
+static int project_get_xattr(const char *pathname, struct fsxattr *fsx,
+ struct stat *st)
{
int ret, fd;
- struct stat st;
- ret = lstat(pathname, &st);
+ ret = lstat(pathname, st);
if (ret) {
fprintf(stderr, "%s: failed to stat '%s': %s\n",
progname, pathname, strerror(errno));
}
/* currently, only file and dir supported */
- if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) {
+ if (!S_ISREG(st->st_mode) && !S_ISDIR(st->st_mode)) {
errno = ENOTSUP;
fprintf(stderr, "%s: unable to get xattr for %s '%s': %s\n",
- progname, mode_to_type(st.st_mode), pathname,
+ progname, mode_to_type(st->st_mode), pathname,
strerror(errno));
return -errno;
}
{
struct fsxattr fsx;
int ret;
+ struct stat st;
- ret = project_get_xattr(pathname, &fsx);
+ ret = project_get_xattr(pathname, &fsx, &st);
if (ret < 0)
return ret;
phc->projid = fsx.fsx_projid;
}
- if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT)) {
+ if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT) &&
+ S_ISDIR(st.st_mode)) {
if (!phc->newline) {
printf("%s%c", pathname, '\0');
goto out;
project_list_one(const char *pathname, struct project_handle_control *phc)
{
struct fsxattr fsx;
+ struct stat st;
int ret;
- ret = project_get_xattr(pathname, &fsx);
+ ret = project_get_xattr(pathname, &fsx, &st);
if (ret < 0)
return ret;
project_set_one(const char *pathname, struct project_handle_control *phc)
{
struct fsxattr fsx;
+ struct stat st;
int fd, ret = 0;
- fd = project_get_xattr(pathname, &fsx);
+ fd = project_get_xattr(pathname, &fsx, &st);
if (fd < 0)
return fd;
project_clear_one(const char *pathname, struct project_handle_control *phc)
{
struct fsxattr fsx;
+ struct stat st;
int ret = 0, fd;
- fd = project_get_xattr(pathname, &fsx);
+ fd = project_get_xattr(pathname, &fsx, &st);
if (fd < 0)
return fd;