3 ** (c) 2004 Herbert Poetzl
18 #include <sys/ioctl.h>
19 #include <sys/types.h>
26 #include "vserver-internal.h"
30 #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE)
32 #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK)
35 static char err_flag = 0;
37 static char opt_xid = 0;
38 static char opt_flag = 0;
39 static char opt_vers = 0;
40 static char opt_add = 0;
41 static char opt_rem = 0;
42 static char opt_set = 0;
44 static char * cmd_name = NULL;
45 static char * set_arg = NULL;
47 static int num_xid = 0;
48 static int num_flag = 0;
53 #define OPTIONS "+hadf:x:S:V"
55 int main(int argc, char *argv[])
64 while ((c = getopt(argc, argv, OPTIONS)) != EOF) {
68 "This is %s " VERSION "\n"
70 "-h print this help message\n"
71 "-a add dlimit entry\n"
72 "-d delete dlimit entry\n"
73 "-f <num> flag value in decimal\n"
74 "-x <num> context id\n"
75 "-S <vals> current/limit values\n"
76 "-V verify interface version\n"
88 num_flag = atol(optarg);
92 num_xid = atol(optarg);
110 "Usage: %s -[" OPTIONS "] <path> ...\n"
117 r = vc_get_version();
119 perror("vc_get_version");
121 printf("version: %04x:%04x\n",
122 (r>>16)&0xFFFF, r&0xFFFF);
125 for (; optind < argc; optind++) {
126 struct vcmd_ctx_dlimit_base_v0 init;
127 struct vcmd_ctx_dlimit_v0 data;
129 init.name = argv[optind];
130 init.flags = num_flag;
133 r = vserver(VCMD_rem_dlimit, num_xid, &init);
135 perror("vc_rem_dlimit");
138 r = vserver(VCMD_add_dlimit, num_xid, &init);
140 perror("vc_add_dlimit");
143 memset(&data, 0, sizeof(data));
144 data.name = argv[optind];
145 data.flags = num_flag;
148 sscanf(set_arg, "%u,%u,%u,%u,%u",
149 &data.space_used, &data.space_total,
150 &data.inodes_used, &data.inodes_total,
153 r = vserver(VCMD_set_dlimit, num_xid, &data);
155 perror("vc_set_dlimit");
158 memset(&data, 0, sizeof(data));
159 data.name = argv[optind];
160 data.flags = num_flag;
162 r = vserver(VCMD_get_dlimit, num_xid, &data);
164 perror("vc_get_dlimit");
166 printf("%s: %u,%u,%u,%u,%u\n", argv[optind],
167 data.space_used, data.space_total,
168 data.inodes_used, data.inodes_total,
172 exit((err_flag)?1:0);