~ubuntu-branches/debian/squeeze/util-vserver/squeeze

« back to all changes in this revision

Viewing changes to .pc/debian-changes-0.30.216-pre2864-2/src/setattr.c

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2010-04-13 12:36:17 UTC
  • Revision ID: james.westby@ubuntu.com-20100413123617-ve6wgautfmwfhnkc
Tags: 0.30.216-pre2864-2
* Switch to dpkg-source 3.0 (quilt) format
* Fix bashisms in helper scripts (Closes: #530995)

Show diffs side-by-side

added added

removed removed

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