while (1) {
int c = getopt_long(argc, argv, CMDLINE_OPTIONS_SHORT,
CMDLINE_OPTIONS, 0);
+ long flags;
+ char *endptr;
if (c==-1) break;
switch (c) {
case CMD_UNSET_BARRIER : args.del_mask |= VC_IATTR_BARRIER; break;
case CMD_UNSET_WRITE : args.del_mask |= VC_IATTR_WRITE; break;
case CMD_UNSET_COW : args.del_mask |= VC_IATTR_COW; break;
+ case CMD_FLAGS :
+ case CMD_UNSET_FLAGS :
+ flags = strtoul(optarg, &endptr, 0);
+ if ((flags == 0 && errno != 0) || *endptr != '\0') {
+ WRITE_MSG(2, "Invalid flags argument: '");
+ WRITE_STR(2, optarg);
+ WRITE_MSG(2, "'; try '--help' for more information\n");
+ return EXIT_FAILURE;
+ }
+ if (c == CMD_FLAGS)
+ args.set_mask |= flags;
+ else
+ args.del_mask |= flags;
+ break;
case 'R' : args.do_recurse = true; break;
case 'a' : args.do_display_dot = true; break;
case 'd' : args.do_display_dir = true; break;
struct option const
CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
+ { "help", no_argument, 0, CMD_HELP },
+ { "version", no_argument, 0, CMD_VERSION },
{ "immu", no_argument, 0, CMD_IMMU },
{ "iunlink", no_argument, 0, CMD_IMMU },
{ "admin", no_argument, 0, CMD_ADMIN },
{ "write", no_argument, 0, CMD_WRITE },
{ "~write", no_argument, 0, CMD_UNSET_WRITE },
{ "!write", no_argument, 0, CMD_UNSET_WRITE },
- { "cow", no_argument, 0, CMD_COW },
- { "~cow", no_argument, 0, CMD_UNSET_COW },
- { "!cow", no_argument, 0, CMD_UNSET_COW },
+ { "cow", no_argument, 0, CMD_COW },
+ { "~cow", no_argument, 0, CMD_UNSET_COW },
+ { "!cow", no_argument, 0, CMD_UNSET_COW },
+ { "ixunlink", no_argument, 0, CMD_IMMUX },
+ { "~ixunlink", no_argument, 0, CMD_UNSET_IMMUX },
+ { "!ixunlink", no_argument, 0, CMD_UNSET_IMMUX },
+ { "flags", required_argument, 0, CMD_FLAGS },
+ { "~flags", required_argument, 0, CMD_UNSET_FLAGS },
{ 0,0,0,0 }
};
WRITE_MSG(fd, "Usage: ");
WRITE_STR(fd, cmd);
WRITE_MSG(fd,
- " [-Rx] [--[~](iunlink|admin|watch|hide|barrier|iunlink-but-not-immutable|immutable|write|cow)]* [--] <file>+\n\n"
+ " [-Rx] [--[~](iunlink|admin|watch|hide|barrier|iunlink-but-not-immutable|immutable|write|cow|ixunlink)]* [--] <file>+\n\n"
" Options:\n"
" -R ... recurse through directories\n"
" -x ... do not cross filesystems\n\n"