Deleted Added
full compact
ls.c (38466) ls.c (38764)
1/*
1/*
2 * $Id$
2 * $Id: ls.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $
3 * From: $NetBSD: ls.c,v 1.3 1997/06/13 13:48:47 drochner Exp $
4 */
5
6/*
7 * Copyright (c) 1993
8 * The Regents of the University of California. All rights reserved.
9 * Copyright (c) 1996
10 * Matthias Drochner. All rights reserved.

--- 41 unchanged lines hidden (view full) ---

52COMMAND_SET(ls, "ls", "list files", command_ls);
53
54static int
55command_ls(int argc, char *argv[])
56{
57 int fd;
58 struct stat sb;
59 size_t size;
3 * From: $NetBSD: ls.c,v 1.3 1997/06/13 13:48:47 drochner Exp $
4 */
5
6/*
7 * Copyright (c) 1993
8 * The Regents of the University of California. All rights reserved.
9 * Copyright (c) 1996
10 * Matthias Drochner. All rights reserved.

--- 41 unchanged lines hidden (view full) ---

52COMMAND_SET(ls, "ls", "list files", command_ls);
53
54static int
55command_ls(int argc, char *argv[])
56{
57 int fd;
58 struct stat sb;
59 size_t size;
60 char dirbuf[DIRBLKSIZ];
61 char pathbuf[128]; /* XXX path length constant? */
62 char buf[128]; /* must be long enough for dir entry! */
60 static char dirbuf[DIRBLKSIZ];
61 static char buf[128]; /* must be long enough for full pathname */
63 char *path;
64 int result, ch;
65#ifdef VERBOSE_LS
66 int verbose;
67
68 verbose = 0;
69 optind = 1;
70 while ((ch = getopt(argc, argv, "l")) != -1) {

--- 62 unchanged lines hidden (view full) ---

133 goto out;
134 }
135
136 if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) {
137#ifdef VERBOSE_LS /* too much UFS activity blows the heap out */
138 if (verbose) {
139 /* stat the file, if possible */
140 sb.st_size = 0;
62 char *path;
63 int result, ch;
64#ifdef VERBOSE_LS
65 int verbose;
66
67 verbose = 0;
68 optind = 1;
69 while ((ch = getopt(argc, argv, "l")) != -1) {

--- 62 unchanged lines hidden (view full) ---

132 goto out;
133 }
134
135 if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) {
136#ifdef VERBOSE_LS /* too much UFS activity blows the heap out */
137 if (verbose) {
138 /* stat the file, if possible */
139 sb.st_size = 0;
141 sprintf(buf, "%s/%s", pathbuf, dp->d_name);
140 sprintf(buf, "%s/%s", path, dp->d_name);
142 /* ignore return */
141 /* ignore return */
143 if (stat(buf, &sb))
142 if (stat(buf, &sb)) {
143 printf("stat(%s) failed: %s\n", buf, strerror(errno));
144 sb.st_size = -1;
144 sb.st_size = -1;
145 }
145 sprintf(buf, " %c %8d %s\n", typestr[dp->d_type], (int)sb.st_size, dp->d_name);
146#endif
147 } else
148 sprintf(buf, " %c %s\n", typestr[dp->d_type], dp->d_name);
149 if (pager_output(buf))
150 goto out;
151 }
152 }
153 dp = (struct direct *) ((char *) dp + dp->d_reclen);
154 }
155 }
156 out:
157 pager_close();
158 close(fd);
159 return(result);
160}
146 sprintf(buf, " %c %8d %s\n", typestr[dp->d_type], (int)sb.st_size, dp->d_name);
147#endif
148 } else
149 sprintf(buf, " %c %s\n", typestr[dp->d_type], dp->d_name);
150 if (pager_output(buf))
151 goto out;
152 }
153 }
154 dp = (struct direct *) ((char *) dp + dp->d_reclen);
155 }
156 }
157 out:
158 pager_close();
159 close(fd);
160 return(result);
161}