126
123
/* note, we ignore names with non-printable widechars */
128
nc->name = strdup(name);
125
nc->name = xstrdup(name);
129
126
else if (asprintf(&nc->name, "%lu", id) == -1)
134
129
for (x = *ic; x && x->next; x = x->next);
224
217
len = strlen(dirname);
225
path = malloc(len + sizeof(DOTDOTDIR));
227
err(EXIT_FAILURE, _("out of memory?"));
218
path = xmalloc(len + sizeof(DOTDOTDIR));
229
220
memcpy(path, dirname, len);
230
221
memcpy(path + len, DOTDOTDIR, sizeof(DOTDOTDIR));
245
nm = calloc(1, sizeof(*nm));
247
err(EXIT_FAILURE, _("out of memory?"));
236
nm = xcalloc(1, sizeof(*nm));
249
238
parent->next = nm;
252
nm->name = strdup(fname);
254
err(EXIT_FAILURE, _("out of memory?"));
241
nm->name = xstrdup(fname);
256
243
nm->noent = (lstat(path, &nm->st) == -1);
403
static void usage(int rc)
422
405
const char *p = program_invocation_short_name;
406
FILE *out = rc == EXIT_FAILURE ? stderr : stdout;
427
printf(_("\nUsage: %s [options] pathname [pathname ...]\n"), p);
428
printf(_("\nOptions:\n"));
431
" -h, --help displays this help text\n"
432
" -x, --mountpoints show mount point directories with a 'D'\n"
433
" -m, --modes show the mode bits of each file\n"
434
" -o, --owners show owner and group name of each file\n"
435
" -l, --long use a long listing format (-m -o -v) \n"
436
" -n, --nosymlinks don't follow symlinks\n"
437
" -v, --vertical vertical align of modes and owners\n"));
439
printf(_("\nFor more information see namei(1).\n"));
411
fputs(_("\nUsage:\n"), out);
413
_(" %s [options] pathname [pathname ...]\n"), p);
415
fputs(_("\nOptions:\n"), out);
416
fputs(_(" -h, --help displays this help text\n"
417
" -V, --version output version information and exit\n"
418
" -x, --mountpoints show mount point directories with a 'D'\n"
419
" -m, --modes show the mode bits of each file\n"
420
" -o, --owners show owner and group name of each file\n"
421
" -l, --long use a long listing format (-m -o -v) \n"
422
" -n, --nosymlinks don't follow symlinks\n"
423
" -v, --vertical vertical align of modes and owners\n"), out);
425
fputs(_("\nFor more information see namei(1).\n"), out);
443
struct option longopts[] =
429
static const struct option longopts[] =
445
431
{ "help", 0, 0, 'h' },
432
{ "version", 0, 0, 'V' },
446
433
{ "mountpoints",0, 0, 'x' },
447
434
{ "modes", 0, 0, 'm' },
448
435
{ "owners", 0, 0, 'o' },
463
449
bindtextdomain(PACKAGE, LOCALEDIR);
464
450
textdomain(PACKAGE);
469
while ((c = getopt_long(argc, argv, "+h?lmnovx", longopts, NULL)) != -1) {
452
while ((c = getopt_long(argc, argv, "hVlmnovx", longopts, NULL)) != -1) {
473
455
usage(EXIT_SUCCESS);
458
printf(_("%s from %s\n"), program_invocation_short_name,
476
462
flags |= (NAMEI_OWNERS | NAMEI_MODES | NAMEI_VERTICAL);