summaryrefslogtreecommitdiff
path: root/misc/lsattr.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>1997-04-26 14:00:26 +0000
committerTheodore Ts'o <tytso@mit.edu>1997-04-26 14:00:26 +0000
commita418d3ad819323f871005d253f7f9ac378e78ba5 (patch)
treebcc26141c6ec23de4bce9cd886a1d085c08a1b69 /misc/lsattr.c
parent50e1e10fa0ac12a3e2a9d20a75ee9041873cda96 (diff)
downloade2fsprogs-a418d3ad819323f871005d253f7f9ac378e78ba5.tar.gz
Many files:
Checked in e2fsprogs 0.5c
Diffstat (limited to 'misc/lsattr.c')
-rw-r--r--misc/lsattr.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/misc/lsattr.c b/misc/lsattr.c
index 6ce190c4..3fe4b9a0 100644
--- a/misc/lsattr.c
+++ b/misc/lsattr.c
@@ -16,12 +16,21 @@
* 94/02/27 - Integrated in Ted's distribution
*/
+#include <sys/types.h>
#include <dirent.h>
+#ifdef HAVE_ERRNO_H
#include <errno.h>
+#endif
#include <fcntl.h>
+#ifdef HAVE_GETOPT_H
#include <getopt.h>
+#else
+extern int optind;
+extern char *optarg;
+#endif
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <linux/ext2_fs.h>
@@ -84,26 +93,28 @@ static void lsattr_args (const char * name)
static int lsattr_dir_proc (const char * dir_name, struct dirent * de, void * private)
{
- char path [MAXPATHLEN];
struct stat st;
+ char *path;
+
+ path = malloc(strlen (dir_name) + 1 + strlen (de->d_name) + 1);
sprintf (path, "%s/%s", dir_name, de->d_name);
if (lstat (path, &st) == -1)
perror (path);
- else
- {
- if (de->d_name[0] != '.' || all)
- {
+ else {
+ if (de->d_name[0] != '.' || all) {
list_attributes (path);
if (S_ISDIR(st.st_mode) && recursive &&
- strcmp (de->d_name, ".") && strcmp (de->d_name, ".."))
- {
+ strcmp(de->d_name, ".") &&
+ strcmp(de->d_name, "..")) {
printf ("\n%s:\n", path);
- iterate_on_dir (path, lsattr_dir_proc, (void *) NULL);
+ iterate_on_dir (path, lsattr_dir_proc,
+ (void *) NULL);
printf ("\n");
}
}
}
+ free(path);
return 0;
}