{ 0,0,0,0 }
};
-char const CMDLINE_OPTIONS_SHORT[] = "Rc:";
+char const CMDLINE_OPTIONS_SHORT[] = "Rc:x";
void
showHelp(int fd, char const *cmd, int res)
WRITE_MSG(fd, "Usage: ");
WRITE_STR(fd, cmd);
WRITE_MSG(fd,
- " -c <ctx|vserver> [-R] [--] <file>+\n\n"
+ " -c <ctx|vserver> [-Rx] [--] <file>+\n\n"
" Options:\n"
" -R ... recurse through directories\n"
" -c ... assign the given context/vserver to the file(s)\n"
+ " -x ... do not cross filesystems\n\n"
"Please report bugs to " PACKAGE_BUGREPORT "\n");
exit(res);
}
exit(0);
}
-static bool
-setFile(char const *name, char const * display_name, struct stat const *exp_st)
+bool
+handleFile(char const *name, char const * display_name)
{
- bool res = false;
- int fd = open(name, O_RDONLY);
-
- if (fd==-1) {
- perror("open()");
- return false;
- }
-
- if (!exp_st ||
- !checkForRace(fd, name, exp_st))
- goto err;
-
- if (vc_X_set_filecontext(fd, global_args->ctx)==-1) {
- //perror("vc_X_set_filecontext()");
+ int rc = vc_set_iattr(name, global_args->ctx, 0, VC_IATTR_XID);
+
+ if (rc==-1) {
perror(display_name);
- goto err;
+ return false;
}
- res = true;
-
- err:
- close(fd);
- return res;
-}
-
-bool
-handleFile(char const *name, char const * display_name,
- struct stat const *exp_st)
-{
- if (S_ISLNK(exp_st->st_mode)) return true;
-
- return setFile(name, display_name, exp_st);
+ return true;
}
void
exit(1);
}
- args->ctx = resolveCtx(args->ctx_str);
+ args->ctx = vc_xidopt2xid(args->ctx_str, true, 0);
+ args->do_display_dir = !args->do_recurse;
+ args->do_display_dot = true;
}