* 93/10/30 - Creation
* 93/11/13 - Replace stat() calls by lstat() to avoid loops
* 94/02/27 - Integrated in Ted's distribution
+ * 98/12/29 - Ignore symlinks when working recursively (G M Sipe)
+ * 98/12/29 - Display version info only when -V specified (G M Sipe)
*/
#include <sys/types.h>
#include <dirent.h>
#include <fcntl.h>
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
unsigned long rf;
unsigned long sf;
-static void volatile fatal_error (const char * fmt_string, int errcode)
+static void fatal_error(const char * fmt_string, int errcode)
{
fprintf (stderr, fmt_string, program_name);
exit (errcode);
}
-#define usage() fatal_error ("usage: %s [-RV] [-+=acdisSu] [-v version] files...\n", \
+#define usage() fatal_error("usage: %s [-RV] [-+=AacdisSu] [-v version] files...\n", \
1)
static int decode_arg (int * i, int argc, char ** argv)
com_err (program_name, errno, "while stating %s", name);
return;
}
+ if (S_ISLNK(st.st_mode) && recursive)
+ return;
if (set)
{
if (verbose)
return 0;
}
-void main (int argc, char ** argv)
+int main (int argc, char ** argv)
{
int i, j;
int end_arg = 0;
- fprintf (stderr, "chattr %s, %s for EXT2 FS %s, %s\n",
- E2FSPROGS_VERSION, E2FSPROGS_DATE,
- EXT2FS_VERSION, EXT2FS_DATE);
if (argc && *argv)
program_name = *argv;
i = 1;
fprintf (stderr, "Must use '-v', =, - or +\n");
exit (1);
}
+ if (verbose)
+ fprintf (stderr, "chattr %s, %s for EXT2 FS %s, %s\n",
+ E2FSPROGS_VERSION, E2FSPROGS_DATE,
+ EXT2FS_VERSION, EXT2FS_DATE);
for (j = i; j < argc; j++)
change_attributes (argv[j]);
+ exit(0);
}