return -1;
}
-static int get_fsid(const char *path, u8 *fsid)
+static int get_fsid(const char *path, u8 *fsid, int silent)
{
int ret;
int fd;
fd = open(path, O_RDONLY);
if (fd < 0) {
ret = -errno;
- fprintf(stderr, "ERROR: open %s failed. %s\n", path,
+ if (!silent)
+ fprintf(stderr, "ERROR: open %s failed. %s\n", path,
strerror(-ret));
goto out;
}
int ret;
u8 fsid[BTRFS_FSID_SIZE];
- ret = get_fsid(object, fsid);
+ ret = get_fsid(object, fsid, 0);
if (ret < 0)
ret = 0;
else
strcat(tmp, "/");
strcat(tmp, "..");
- ret = get_fsid(object, fsid);
+ ret = get_fsid(object, fsid, 0);
if (ret < 0) {
fprintf(stderr, "ERROR: get_fsid for %s failed. %s\n", object,
strerror(-ret));
goto out;
}
- ret = get_fsid(tmp, fsid2);
- if (ret < 0) {
+ ret = get_fsid(tmp, fsid2, 1);
+ if (ret == -ENOTTY) {
ret = 0;
goto out;
+ } else if (ret == -ENOTDIR) {
+ ret = 1;
+ goto out;
+ } else if (ret < 0) {
+ fprintf(stderr, "ERROR: get_fsid for %s failed. %s\n", tmp,
+ strerror(-ret));
+ goto out;
}
- if (!memcmp(fsid, fsid2, BTRFS_FSID_SIZE)) {
+ if (memcmp(fsid, fsid2, BTRFS_FSID_SIZE)) {
ret = 0;
goto out;
}
ret = check_is_root(object);
if (ret < 0)
goto out;
- if (ret)
+ if (!ret)
types |= prop_object_root;
}