/[baselayout]/trunk/src/mountinfo.c
Gentoo

Diff of /trunk/src/mountinfo.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2582 Revision 2603
125} 125}
126 126
127#else 127#else
128# error "Operating system not supported!" 128# error "Operating system not supported!"
129#endif 129#endif
130
131#define getoptstring "F:N:S:fnrhV"
132static struct option longopts[] = {
133 { "fstype-regex", 1, NULL, 'F'},
134 { "node-regex", 1, NULL, 'N'},
135 { "skip-regex", 1, NULL, 'S'},
136 { "fstype", 0, NULL, 'f'},
137 { "node", 0, NULL, 'n'},
138 { "reverse", 0, NULL, 'r'},
139 { "help", 0, NULL, 'h'},
140 { NULL, 0, NULL, 0}
141};
142
143static void usage (int exit_status)
144{
145 int i;
146 printf ("Usage: mountinfo [options]\n\n");
147 printf ("Options:\n");
148 for (i = 0; longopts[i].name; ++i)
149 printf (" -%c, --%s\n", longopts[i].val, longopts[i].name);
150 exit (exit_status);
151}
130 152
131int main (int argc, char **argv) 153int main (int argc, char **argv)
132{ 154{
133 int i; 155 int i;
134 regex_t *fstype_regex = NULL; 156 regex_t *fstype_regex = NULL;
142 bool list_fstype = false; 164 bool list_fstype = false;
143 bool reverse = false; 165 bool reverse = false;
144 char **mounts = NULL; 166 char **mounts = NULL;
145 char c; 167 char c;
146 168
147 static struct option longopts[] = {
148 { "fstype-regex", 1, NULL, 'F'},
149 { "node-regex", 1, NULL, 'N'},
150 { "skip-regex", 1, NULL, 'S'},
151 { "fstype", 0, NULL, 'f'},
152 { "node", 0, NULL, 'n'},
153 { "reverse", 0, NULL, 'r'},
154 { NULL, 0, NULL, 0}
155 };
156
157 while ((c = getopt_long (argc, argv, "F:N:S:fnr", 169 while ((c = getopt_long (argc, argv, getoptstring,
158 longopts, (int *) 0)) != -1) 170 longopts, (int *) 0)) != -1)
159 switch (c) { 171 switch (c) {
160 case 'F': 172 case 'F':
161 if (fstype_regex) 173 if (fstype_regex)
162 free (fstype_regex); 174 free (fstype_regex);
205 217
206 case 'r': 218 case 'r':
207 reverse = true; 219 reverse = true;
208 break; 220 break;
209 221
222 case 'h':
223 usage (EXIT_SUCCESS);
224
210 default: 225 default:
211 exit (EXIT_FAILURE); 226 usage (EXIT_FAILURE);
212 } 227 }
213 228
214 while (optind < argc) { 229 while (optind < argc) {
215 if (argv[optind][0] != '/') 230 if (argv[optind][0] != '/')
216 eerrorx ("%s: `%s' is not a mount point", argv[0], argv[optind]); 231 eerrorx ("%s: `%s' is not a mount point", argv[0], argv[optind]);
239 if (skip_regex) 254 if (skip_regex)
240 free (skip_regex); 255 free (skip_regex);
241 256
242 exit (result); 257 exit (result);
243} 258}
244

Legend:
Removed from v.2582  
changed lines
  Added in v.2603

  ViewVC Help
Powered by ViewVC 1.1.20