X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fchxid.c;h=596f0a9e58af32dee69d156eb35cd6c2631c79e3;hb=a8fa6daead9e88f6d4b1934490b69bf261c845e6;hp=72358475cbeb9650636863ad2f613598b7e69ae4;hpb=9c78378bebc1a9f3d400f422df8ede9efea57dea;p=util-vserver.git diff --git a/src/chxid.c b/src/chxid.c index 7235847..596f0a9 100644 --- a/src/chxid.c +++ b/src/chxid.c @@ -38,7 +38,7 @@ CMDLINE_OPTIONS[] = { { 0,0,0,0 } }; -char const CMDLINE_OPTIONS_SHORT[] = "Rc:x"; +char const CMDLINE_OPTIONS_SHORT[] = "Rc:xU"; void showHelp(int fd, char const *cmd, int res) @@ -46,11 +46,12 @@ showHelp(int fd, char const *cmd, int res) WRITE_MSG(fd, "Usage: "); WRITE_STR(fd, cmd); WRITE_MSG(fd, - " -c [-Rx] [--] +\n\n" + " -c [-RxU] [--] +\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" + " -x ... do not cross filesystems\n" + " -U ... skip unified files\n\n" "Please report bugs to " PACKAGE_BUGREPORT "\n"); exit(res); } @@ -66,14 +67,30 @@ showVersion() exit(0); } +static inline bool +isUnified(char const *filename) +{ + uint_least32_t const V = VC_IATTR_IUNLINK|VC_IATTR_IMMUTABLE; + + uint_least32_t flags; + uint_least32_t mask = V; + + if (vc_get_iattr(filename, 0, &flags, &mask)==-1 || (mask & V) != V) + return false; + + return (flags & V)==V ? true : false; +} + bool handleFile(char const *name, char const * display_name) { - int rc = vc_set_iattr(name, global_args->ctx, 0, VC_IATTR_XID); + if (!global_args->no_unified || !isUnified(name)) { + int rc = vc_set_iattr(name, global_args->ctx, 0, VC_IATTR_XID); - if (rc==-1) { - perror(display_name); - return false; + if (rc==-1) { + perror(display_name); + return false; + } } return true; @@ -92,7 +109,7 @@ fixupParams(struct Arguments UNUSED *args, int argc) exit(1); } - args->ctx = vc_xidopt2xid(args->ctx_str, true, 0); + args->ctx = vc_tagopt2tag(args->ctx_str, true, 0); args->do_display_dir = !args->do_recurse; args->do_display_dot = true; }