summaryrefslogtreecommitdiff
path: root/misc-utils
diff options
context:
space:
mode:
authorLaMont Jones <lamont@debian.org>2010-10-18 06:49:27 -0600
committerLaMont Jones <lamont@debian.org>2010-10-18 06:49:27 -0600
commite61e0ca7d872870ca843133c4c60c6b8992d7bca (patch)
tree2a9fd5e4737bfdd994697a022030387e9437460a /misc-utils
parenteb3eeb38b6129c7236e9661e12f49bf8e42c085f (diff)
parent973af806428c0f853ac0241ab46faee6ccdaab26 (diff)
downloadutil-linux-old-e61e0ca7d872870ca843133c4c60c6b8992d7bca.tar.gz
Merge remote branch 'origin/master'
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/cal.c22
-rw-r--r--misc-utils/ddate.12
-rw-r--r--misc-utils/findmnt.c2
-rw-r--r--misc-utils/namei.c37
4 files changed, 37 insertions, 26 deletions
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 65d517a8..4d46c1b1 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -64,6 +64,7 @@
#include <time.h>
#include <unistd.h>
#include <err.h>
+#include <errno.h>
#include "c.h"
#include "nls.h"
@@ -257,21 +258,14 @@ void monthly3(int, int, int);
void trim_trailing_spaces(char *);
void usage(void);
void headers_init(void);
-extern char *__progname;
int
main(int argc, char **argv) {
struct tm *local_time;
time_t now;
int ch, day, month, year, yflag;
- char *progname, *p;
int num_months = NUM_MONTHS;
- progname = argv[0];
- if ((p = strrchr(progname, '/')) != NULL)
- progname = p+1;
- __progname = progname;
-
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@@ -345,9 +339,9 @@ main(int argc, char **argv) {
yflag = 1;
break;
case 'V':
- printf(_("%s from %s\n"),
- progname, PACKAGE_STRING);
- return 0;
+ printf(_("%s from %s\n"), program_invocation_short_name,
+ PACKAGE_STRING);
+ return EXIT_SUCCESS;
case '?':
default:
usage();
@@ -403,7 +397,8 @@ main(int argc, char **argv) {
monthly(day, month, year);
else if (num_months == 3)
monthly3(day, month, year);
- exit(0);
+
+ return EXIT_SUCCESS;
}
void headers_init(void)
@@ -783,6 +778,7 @@ void
usage()
{
- fprintf(stderr, _("usage: cal [-13smjyV] [[[day] month] year]\n"));
- exit(1);
+ fprintf(stderr, _("usage: %s [-13smjyV] [[[day] month] year]\n"),
+ program_invocation_short_name);
+ exit(EXIT_FAILURE);
}
diff --git a/misc-utils/ddate.1 b/misc-utils/ddate.1
index 6928f959..67b2057e 100644
--- a/misc-utils/ddate.1
+++ b/misc-utils/ddate.1
@@ -78,7 +78,7 @@ Today's St. Tib's Day, 3162.
.SH BUGS
.B ddate(1)
-will produce undefined behaviour if asked to produce the date for St. Tib's
+will produce undefined behavior if asked to produce the date for St. Tib's
day and its format string does not contain the St. Tib's Day delimiters
%{ and %}.
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 21a3566c..b1fb90a4 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -547,7 +547,7 @@ int main(int argc, char *argv[])
tt_flags |= TT_FL_TREE;
while ((c = getopt_long(argc, argv,
- "cd:ehifo:O:klmnrst:uS:T:", longopts, NULL)) != -1) {
+ "acd:ehifo:O:klmnrst:uS:T:", longopts, NULL)) != -1) {
switch(c) {
case 'a':
tt_flags |= TT_FL_ASCII;
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index 6853e1ec..9873cda9 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -60,6 +60,7 @@ struct namei {
struct namei *next; /* next item */
int level;
int mountpoint; /* is mount point */
+ int noent; /* is this item not existing */
};
struct idcache {
@@ -250,8 +251,10 @@ new_namei(struct namei *parent, const char *path, const char *fname, int lev)
nm->name = strdup(fname);
if (!nm->name)
err(EXIT_FAILURE, _("out of memory?"));
- if (lstat(path, &nm->st) == -1)
- err(EXIT_FAILURE, _("could not stat '%s'"), path);
+
+ nm->noent = (lstat(path, &nm->st) == -1);
+ if (nm->noent)
+ return nm;
if (S_ISLNK(nm->st.st_mode))
readlink_to_namei(nm, path);
@@ -331,7 +334,6 @@ add_namei(struct namei *parent, const char *orgpath, int start, struct namei **l
return first;
}
-
static int
follow_symlinks(struct namei *nm)
{
@@ -340,6 +342,8 @@ follow_symlinks(struct namei *nm)
for (; nm; nm = nm->next) {
struct namei *next, *last;
+ if (nm->noent)
+ continue;
if (!S_ISLNK(nm->st.st_mode))
continue;
if (++symcount > MAXSYMLINKS) {
@@ -394,7 +398,7 @@ strmode(mode_t mode, char *str)
str[10] = '\0';
}
-static void
+static int
print_namei(struct namei *nm, char *path)
{
struct namei *prev = NULL;
@@ -406,6 +410,11 @@ print_namei(struct namei *nm, char *path)
for (; nm; prev = nm, nm = nm->next) {
char md[11];
+ if (nm->noent) {
+ printf(_("%s - No such file or directory\n"), nm->name);
+ return -1;
+ }
+
strmode(nm->st.st_mode, md);
if (nm->mountpoint)
@@ -439,6 +448,7 @@ print_namei(struct namei *nm, char *path)
else
printf(" %s\n", nm->name);
}
+ return 0;
}
static void
@@ -482,6 +492,7 @@ main(int argc, char **argv)
{
extern int optind;
int c;
+ int rc = EXIT_SUCCESS;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -522,25 +533,29 @@ main(int argc, char **argv)
struct stat st;
if (stat(path, &st) != 0)
- err(EXIT_FAILURE, _("failed to stat: %s"), path);
+ rc = EXIT_FAILURE;
nm = add_namei(NULL, path, 0, NULL);
if (nm) {
int sml = 0;
if (!(flags & NAMEI_NOLINKS))
sml = follow_symlinks(nm);
- print_namei(nm, path);
+ if (print_namei(nm, path)) {
+ rc = EXIT_FAILURE;
+ continue;
+ }
free_namei(nm);
- if (sml == -1)
- errx(EXIT_FAILURE,
- _("%s: exceeded limit of symlinks"),
- path);
+ if (sml == -1) {
+ rc = EXIT_FAILURE;
+ warnx(_("%s: exceeded limit of symlinks"), path);
+ continue;
+ }
}
}
free_idcache(ucache);
free_idcache(gcache);
- return EXIT_SUCCESS;
+ return rc;
}