1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
// $Id: setattr.c 2732 2008-07-11 15:20:35Z dhozac $ --*- c -*--
// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "fstool.h"
#include "util.h"
#include <lib/fmt.h>
#include <lib/vserver.h>
#include <lib/vserver-internal.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
struct option const
CMDLINE_OPTIONS[] = {
{ "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 },
{ "watch", no_argument, 0, CMD_WATCH },
{ "hide", no_argument, 0, CMD_HIDE },
{ "barrier", no_argument, 0, CMD_BARRIER },
{ "~iunlink", no_argument, 0, CMD_UNSET_IMMU },
{ "!iunlink", no_argument, 0, CMD_UNSET_IMMU },
{ "~immu", no_argument, 0, CMD_UNSET_IMMU },
{ "!immu", no_argument, 0, CMD_UNSET_IMMU },
{ "~admin", no_argument, 0, CMD_UNSET_ADMIN },
{ "!admin", no_argument, 0, CMD_UNSET_ADMIN },
{ "~watch", no_argument, 0, CMD_UNSET_WATCH },
{ "!watch", no_argument, 0, CMD_UNSET_WATCH },
{ "~hide", no_argument, 0, CMD_UNSET_HIDE },
{ "!hide", no_argument, 0, CMD_UNSET_HIDE },
{ "~barrier", no_argument, 0, CMD_UNSET_BARRIER },
{ "!barrier", no_argument, 0, CMD_UNSET_BARRIER },
{ "iunlink-but-not-immutable", no_argument, 0, CMD_IMMUX },
{ "~iunlink-but-not-immutable", no_argument, 0, CMD_UNSET_IMMUX },
{ "!iunlink-but-not-immutable", no_argument, 0, CMD_UNSET_IMMUX },
{ "immutable", no_argument, 0, CMD_IMMUTABLE },
{ "~immutable", no_argument, 0, CMD_UNSET_IMMUTABLE },
{ "!immutable", no_argument, 0, CMD_UNSET_IMMUTABLE },
{ "write", no_argument, 0, CMD_WRITE },
{ "~write", no_argument, 0, CMD_UNSET_WRITE },
{ "!write", no_argument, 0, CMD_UNSET_WRITE },
{ 0,0,0,0 }
};
char const CMDLINE_OPTIONS_SHORT[] = "Rx";
void
showHelp(int fd, char const *cmd, int res)
{
WRITE_MSG(fd, "Usage: ");
WRITE_STR(fd, cmd);
WRITE_MSG(fd,
" [-Rx] [--[~](iunlink|admin|watch|hide|barrier|iunlink-but-not-immutable|immutable|write)]* [--] <file>+\n\n"
" Options:\n"
" -R ... recurse through directories\n"
" -x ... do not cross filesystems\n\n"
"Please report bugs to " PACKAGE_BUGREPORT "\n");
exit(res);
}
void
showVersion()
{
WRITE_MSG(1,
"setattr " VERSION " -- sets vserver specific file attributes\n"
"This program is part of " PACKAGE_STRING "\n\n"
"Copyright (C) 2004 Enrico Scholz\n"
VERSION_COPYRIGHT_DISCLAIMER);
exit(0);
}
void
fixupParams(struct Arguments * args, int argc)
{
if (optind==argc) {
WRITE_MSG(2, "No filename given; use '--help' for more information\n");
exit(1);
}
args->do_display_dir = !args->do_recurse;
args->do_display_dot = true;
}
bool
handleFile(char const *name, char const * display_name)
{
int rc = vc_set_iattr(name,
0,
global_args->set_mask & ~global_args->del_mask,
global_args->set_mask | global_args->del_mask);
if (rc==-1) {
perror(display_name);
return false;
}
return true;
}
|