bbify to shrink size
This commit is contained in:
@@ -36,270 +36,200 @@
|
|||||||
#define EXT2FS_ATTR(x)
|
#define EXT2FS_ATTR(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef S_ISLNK /* So we can compile even with gcc-warn */
|
|
||||||
# ifdef __S_IFLNK
|
|
||||||
# define S_ISLNK(mode) __S_ISTYPE((mode), __S_IFLNK)
|
|
||||||
# else
|
|
||||||
# define S_ISLNK(mode) 0
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "e2fsbb.h"
|
#include "e2fsbb.h"
|
||||||
#include "e2p/e2p.h"
|
#include "e2p/e2p.h"
|
||||||
|
|
||||||
static int add;
|
#define OPT_ADD 1
|
||||||
static int rem;
|
#define OPT_REM 2
|
||||||
static int set;
|
#define OPT_SET 4
|
||||||
static int set_version;
|
#define OPT_SET_VER 8
|
||||||
|
static int flags;
|
||||||
|
static int recursive;
|
||||||
|
|
||||||
static unsigned long version;
|
static unsigned long version;
|
||||||
|
|
||||||
static int recursive;
|
|
||||||
static int verbose;
|
|
||||||
|
|
||||||
static unsigned long af;
|
static unsigned long af;
|
||||||
static unsigned long rf;
|
static unsigned long rf;
|
||||||
static unsigned long sf;
|
static unsigned long sf;
|
||||||
|
|
||||||
#ifdef _LFS64_LARGEFILE
|
#ifdef CONFIG_LFS
|
||||||
#define LSTAT lstat64
|
# define LSTAT lstat64
|
||||||
#define STRUCT_STAT struct stat64
|
# define STRUCT_STAT struct stat64
|
||||||
#else
|
#else
|
||||||
#define LSTAT lstat
|
# define LSTAT lstat
|
||||||
#define STRUCT_STAT struct stat
|
# define STRUCT_STAT struct stat
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
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] [-+=AacDdijsSu] [-v version] files...\n"), \
|
|
||||||
1)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct flags_char {
|
struct flags_char {
|
||||||
unsigned long flag;
|
unsigned long flag;
|
||||||
char optchar;
|
char optchar;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct flags_char flags_array[] = {
|
static const struct flags_char flags_array[] = {
|
||||||
{ EXT2_NOATIME_FL, 'A' },
|
{ EXT2_NOATIME_FL, 'A' },
|
||||||
{ EXT2_SYNC_FL, 'S' },
|
{ EXT2_SYNC_FL, 'S' },
|
||||||
{ EXT2_DIRSYNC_FL, 'D' },
|
{ EXT2_DIRSYNC_FL, 'D' },
|
||||||
{ EXT2_APPEND_FL, 'a' },
|
{ EXT2_APPEND_FL, 'a' },
|
||||||
{ EXT2_COMPR_FL, 'c' },
|
{ EXT2_COMPR_FL, 'c' },
|
||||||
{ EXT2_NODUMP_FL, 'd' },
|
{ EXT2_NODUMP_FL, 'd' },
|
||||||
{ EXT2_IMMUTABLE_FL, 'i' },
|
{ EXT2_IMMUTABLE_FL, 'i' },
|
||||||
{ EXT3_JOURNAL_DATA_FL, 'j' },
|
{ EXT3_JOURNAL_DATA_FL, 'j' },
|
||||||
{ EXT2_SECRM_FL, 's' },
|
{ EXT2_SECRM_FL, 's' },
|
||||||
{ EXT2_UNRM_FL, 'u' },
|
{ EXT2_UNRM_FL, 'u' },
|
||||||
{ EXT2_NOTAIL_FL, 't' },
|
{ EXT2_NOTAIL_FL, 't' },
|
||||||
{ EXT2_TOPDIR_FL, 'T' },
|
{ EXT2_TOPDIR_FL, 'T' },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned long get_flag(char c)
|
static unsigned long get_flag(char c)
|
||||||
{
|
{
|
||||||
const struct flags_char *fp;
|
const struct flags_char *fp;
|
||||||
|
for (fp = flags_array; fp->flag; fp++)
|
||||||
for (fp = flags_array; fp->flag != 0; fp++) {
|
|
||||||
if (fp->optchar == c)
|
if (fp->optchar == c)
|
||||||
return fp->flag;
|
return fp->flag;
|
||||||
}
|
bb_show_usage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int decode_arg(char *arg)
|
||||||
static int decode_arg (int * i, int argc, char ** argv)
|
|
||||||
{
|
{
|
||||||
char * p;
|
unsigned long *fl;
|
||||||
char * tmp;
|
char opt = *arg++;
|
||||||
unsigned long fl;
|
|
||||||
|
|
||||||
switch (argv[*i][0])
|
if (opt == '-') {
|
||||||
{
|
flags |= OPT_REM;
|
||||||
case '-':
|
fl = &rf;
|
||||||
for (p = &argv[*i][1]; *p; p++) {
|
} else if (opt == '+') {
|
||||||
if (*p == 'R') {
|
flags |= OPT_ADD;
|
||||||
recursive = 1;
|
fl = ⁡
|
||||||
continue;
|
} else if (opt == '=') {
|
||||||
}
|
flags |= OPT_SET;
|
||||||
if (*p == 'V') {
|
fl = &sf;
|
||||||
verbose = 1;
|
} else
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (*p == 'v') {
|
|
||||||
(*i)++;
|
|
||||||
if (*i >= argc)
|
|
||||||
usage ();
|
|
||||||
version = strtol (argv[*i], &tmp, 0);
|
|
||||||
if (*tmp) {
|
|
||||||
com_err (program_name, 0,
|
|
||||||
_("bad version - %s\n"),
|
|
||||||
argv[*i]);
|
|
||||||
usage ();
|
|
||||||
}
|
|
||||||
set_version = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ((fl = get_flag(*p)) == 0)
|
|
||||||
usage();
|
|
||||||
rf |= fl;
|
|
||||||
rem = 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '+':
|
|
||||||
add = 1;
|
|
||||||
for (p = &argv[*i][1]; *p; p++) {
|
|
||||||
if ((fl = get_flag(*p)) == 0)
|
|
||||||
usage();
|
|
||||||
af |= fl;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '=':
|
|
||||||
set = 1;
|
|
||||||
for (p = &argv[*i][1]; *p; p++) {
|
|
||||||
if ((fl = get_flag(*p)) == 0)
|
|
||||||
usage();
|
|
||||||
sf |= fl;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return EOF;
|
return EOF;
|
||||||
break;
|
|
||||||
}
|
for (; *arg ; ++arg)
|
||||||
|
(*fl) |= get_flag(*arg);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int chattr_dir_proc (const char *, struct dirent *, void *);
|
static int chattr_dir_proc(const char *, struct dirent *, void *);
|
||||||
|
|
||||||
static void change_attributes (const char * name)
|
static void change_attributes(const char * name)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long fsflags;
|
||||||
STRUCT_STAT st;
|
STRUCT_STAT st;
|
||||||
|
|
||||||
if (LSTAT (name, &st) == -1) {
|
if (LSTAT(name, &st) == -1) {
|
||||||
com_err (program_name, errno, _("while trying to stat %s"),
|
bb_error_msg("while trying to stat %s", name);
|
||||||
name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (S_ISLNK(st.st_mode) && recursive)
|
if (S_ISLNK(st.st_mode) && recursive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Don't try to open device files, fifos etc. We probably
|
/* Don't try to open device files, fifos etc. We probably
|
||||||
ought to display an error if the file was explicitly given
|
* ought to display an error if the file was explicitly given
|
||||||
on the command line (whether or not recursive was
|
* on the command line (whether or not recursive was
|
||||||
requested). */
|
* requested). */
|
||||||
if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode) &&
|
if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode) && !S_ISDIR(st.st_mode))
|
||||||
!S_ISDIR(st.st_mode))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (set) {
|
if (flags & OPT_SET_VER)
|
||||||
if (verbose) {
|
if (fsetversion(name, version) == -1)
|
||||||
printf (_("Flags of %s set as "), name);
|
bb_error_msg("while setting version on %s", name);
|
||||||
print_flags (stdout, sf, 0);
|
|
||||||
printf ("\n");
|
if (flags & OPT_SET) {
|
||||||
}
|
fsflags = sf;
|
||||||
if (fsetflags (name, sf) == -1)
|
|
||||||
perror (name);
|
|
||||||
} else {
|
} else {
|
||||||
if (fgetflags (name, &flags) == -1)
|
if (fgetflags(name, &fsflags) == -1) {
|
||||||
com_err (program_name, errno,
|
bb_error_msg("while reading flags on %s", name);
|
||||||
_("while reading flags on %s"), name);
|
goto skip_setflags;
|
||||||
else {
|
|
||||||
if (rem)
|
|
||||||
flags &= ~rf;
|
|
||||||
if (add)
|
|
||||||
flags |= af;
|
|
||||||
if (verbose) {
|
|
||||||
printf (_("Flags of %s set as "), name);
|
|
||||||
print_flags (stdout, flags, 0);
|
|
||||||
printf ("\n");
|
|
||||||
}
|
|
||||||
if (!S_ISDIR(st.st_mode))
|
|
||||||
flags &= ~EXT2_DIRSYNC_FL;
|
|
||||||
if (fsetflags (name, flags) == -1)
|
|
||||||
com_err (program_name, errno,
|
|
||||||
_("while setting flags on %s"), name);
|
|
||||||
}
|
}
|
||||||
|
if (flags & OPT_REM)
|
||||||
|
fsflags &= ~rf;
|
||||||
|
if (flags & OPT_ADD)
|
||||||
|
fsflags |= af;
|
||||||
|
if (!S_ISDIR(st.st_mode))
|
||||||
|
fsflags &= ~EXT2_DIRSYNC_FL;
|
||||||
}
|
}
|
||||||
if (set_version) {
|
if (fsetflags(name, fsflags) == -1)
|
||||||
if (verbose)
|
bb_error_msg("while setting flags on %s", name);
|
||||||
printf (_("Version of %s set as %lu\n"), name, version);
|
|
||||||
if (fsetversion (name, version) == -1)
|
skip_setflags:
|
||||||
com_err (program_name, errno,
|
|
||||||
_("while setting version on %s"), name);
|
|
||||||
}
|
|
||||||
if (S_ISDIR(st.st_mode) && recursive)
|
if (S_ISDIR(st.st_mode) && recursive)
|
||||||
iterate_on_dir (name, chattr_dir_proc, NULL);
|
iterate_on_dir(name, chattr_dir_proc, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int chattr_dir_proc (const char * dir_name, struct dirent * de,
|
static int chattr_dir_proc(const char *dir_name, struct dirent *de,
|
||||||
void * private EXT2FS_ATTR((unused)))
|
void *private EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
if (strcmp (de->d_name, ".") && strcmp (de->d_name, "..")) {
|
/*if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {*/
|
||||||
char *path;
|
if (de->d_name[0] == '.' && (de->d_name[1] == '\0' || \
|
||||||
|
(de->d_name[1] == '.' && de->d_name[2] == '\0'))) {
|
||||||
|
|
||||||
path = malloc(strlen (dir_name) + 1 + strlen (de->d_name) + 1);
|
char *path = malloc(strlen(dir_name) + 1 + strlen(de->d_name) + 1);
|
||||||
if (!path)
|
if (!path)
|
||||||
fatal_error(_("Couldn't allocate path variable "
|
bb_error_msg_and_die("Couldn't allocate path variable in chattr_dir_proc");
|
||||||
"in chattr_dir_proc"), 1);
|
sprintf(path, "%s/%s", dir_name, de->d_name);
|
||||||
sprintf (path, "%s/%s", dir_name, de->d_name);
|
change_attributes(path);
|
||||||
change_attributes (path);
|
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int chattr_main (int argc, char ** argv)
|
int chattr_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i;
|
||||||
int end_arg = 0;
|
char *arg;
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
/* parse the args */
|
||||||
setlocale(LC_MESSAGES, "");
|
for (i = 1; i < argc; ++i) {
|
||||||
setlocale(LC_CTYPE, "");
|
arg = argv[i];
|
||||||
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
||||||
textdomain(NLS_CAT_NAME);
|
/* take care of -R and -v <version> */
|
||||||
#endif
|
if (arg[0] == '-') {
|
||||||
#if 0
|
if (arg[1] == 'R' && arg[2] == '\0') {
|
||||||
if (argc && *argv)
|
recursive = 1;
|
||||||
program_name = *argv;
|
continue;
|
||||||
#endif
|
} else if (arg[1] == 'v' && arg[2] == '\0') {
|
||||||
i = 1;
|
char *tmp;
|
||||||
while (i < argc && !end_arg) {
|
++i;
|
||||||
/* '--' arg should end option processing */
|
if (i >= argc)
|
||||||
if (strcmp(argv[i], "--") == 0) {
|
bb_show_usage();
|
||||||
i++;
|
version = strtol(argv[i], &tmp, 0);
|
||||||
end_arg = 1;
|
if (*tmp) {
|
||||||
} else if (decode_arg (&i, argc, argv) == EOF)
|
bb_error_msg("bad version - %s", arg);
|
||||||
end_arg = 1;
|
bb_show_usage();
|
||||||
else
|
}
|
||||||
i++;
|
flags |= OPT_SET_VER;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decode_arg(arg) == EOF)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* run sanity checks on all the arguments given us */
|
||||||
if (i >= argc)
|
if (i >= argc)
|
||||||
usage ();
|
bb_show_usage();
|
||||||
if (set && (add || rem)) {
|
if ((flags & OPT_SET) && ((flags & OPT_ADD) || (flags & OPT_REM))) {
|
||||||
fputs(_("= is incompatible with - and +\n"), stderr);
|
bb_error_msg("= is incompatible with - and +");
|
||||||
exit (1);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if ((rf & af) != 0) {
|
if ((rf & af) != 0) {
|
||||||
fputs("Can't both set and unset same flag.\n", stderr);
|
bb_error_msg("Can't both set and unset same flag");
|
||||||
exit (1);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (!(add || rem || set || set_version)) {
|
if (!flags) {
|
||||||
fputs(_("Must use '-v', =, - or +\n"), stderr);
|
bb_error_msg("Must use '-v', =, - or +");
|
||||||
exit (1);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (verbose)
|
/* now run chattr on all the files passed to us */
|
||||||
fprintf (stderr, "chattr %s (%s)\n",
|
while (i < argc)
|
||||||
E2FSPROGS_VERSION, E2FSPROGS_DATE);
|
change_attributes(argv[i++]);
|
||||||
#endif
|
|
||||||
for (j = i; j < argc; j++)
|
return EXIT_SUCCESS;
|
||||||
change_attributes (argv[j]);
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
@@ -39,99 +39,87 @@
|
|||||||
#define EXT2FS_ATTR(x)
|
#define EXT2FS_ATTR(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int all;
|
#define OPT_RECUR 1
|
||||||
static int dirs_opt;
|
#define OPT_ALL 2
|
||||||
static unsigned pf_options;
|
#define OPT_DIRS_OPT 4
|
||||||
static int recursive;
|
#define OPT_PF_LONG 8
|
||||||
static int verbose;
|
#define OPT_GENERATION 16
|
||||||
static int generation_opt;
|
static int flags;
|
||||||
|
|
||||||
#ifdef _LFS64_LARGEFILE
|
#ifdef CONFIG_LFS
|
||||||
#define LSTAT lstat64
|
# define LSTAT lstat64
|
||||||
#define STRUCT_STAT struct stat64
|
# define STRUCT_STAT struct stat64
|
||||||
#else
|
#else
|
||||||
#define LSTAT lstat
|
# define LSTAT lstat
|
||||||
#define STRUCT_STAT struct stat
|
# define STRUCT_STAT struct stat
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
static void list_attributes(const char *name)
|
||||||
static void usage(void)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("Usage: %s [-RVadlv] [files...]\n"), program_name);
|
unsigned long fsflags;
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void list_attributes (const char * name)
|
|
||||||
{
|
|
||||||
unsigned long flags;
|
|
||||||
unsigned long generation;
|
unsigned long generation;
|
||||||
|
|
||||||
if (fgetflags (name, &flags) == -1) {
|
if (fgetflags(name, &fsflags) == -1) {
|
||||||
com_err (program_name, errno, _("While reading flags on %s"),
|
bb_perror_msg("While reading flags on %s", name);
|
||||||
name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (generation_opt) {
|
if (flags & OPT_GENERATION) {
|
||||||
if (fgetversion (name, &generation) == -1) {
|
if (fgetversion(name, &generation) == -1) {
|
||||||
com_err (program_name, errno,
|
bb_perror_msg("While reading version on %s", name);
|
||||||
_("While reading version on %s"),
|
|
||||||
name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf ("%5lu ", generation);
|
printf("%5lu ", generation);
|
||||||
}
|
}
|
||||||
if (pf_options & PFOPT_LONG) {
|
if (flags & OPT_PF_LONG) {
|
||||||
printf("%-28s ", name);
|
printf("%-28s ", name);
|
||||||
print_flags(stdout, flags, pf_options);
|
print_flags(stdout, fsflags, PFOPT_LONG);
|
||||||
fputc('\n', stdout);
|
fputc('\n', stdout);
|
||||||
} else {
|
} else {
|
||||||
print_flags(stdout, flags, pf_options);
|
print_flags(stdout, fsflags, 0);
|
||||||
printf(" %s\n", name);
|
printf(" %s\n", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lsattr_dir_proc (const char *, struct dirent *, void *);
|
static int lsattr_dir_proc(const char *, struct dirent *, void *);
|
||||||
|
|
||||||
static void lsattr_args (const char * name)
|
static void lsattr_args(const char *name)
|
||||||
{
|
{
|
||||||
STRUCT_STAT st;
|
STRUCT_STAT st;
|
||||||
|
|
||||||
if (LSTAT (name, &st) == -1)
|
if (LSTAT(name, &st) == -1)
|
||||||
com_err (program_name, errno, _("while trying to stat %s"),
|
bb_perror_msg("while trying to stat %s", name);
|
||||||
name);
|
|
||||||
else {
|
else {
|
||||||
if (S_ISDIR(st.st_mode) && !dirs_opt)
|
if (S_ISDIR(st.st_mode) && !(flags & OPT_DIRS_OPT))
|
||||||
iterate_on_dir (name, lsattr_dir_proc, NULL);
|
iterate_on_dir(name, lsattr_dir_proc, NULL);
|
||||||
else
|
else
|
||||||
list_attributes (name);
|
list_attributes(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lsattr_dir_proc (const char * dir_name, struct dirent * de,
|
static int lsattr_dir_proc(const char *dir_name, struct dirent *de,
|
||||||
void * private EXT2FS_ATTR((unused)))
|
void *private EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
STRUCT_STAT st;
|
STRUCT_STAT st;
|
||||||
char *path;
|
char *path;
|
||||||
int dir_len = strlen(dir_name);
|
int dir_len = strlen(dir_name);
|
||||||
|
|
||||||
path = malloc(dir_len + strlen (de->d_name) + 2);
|
path = malloc(dir_len + strlen(de->d_name) + 2);
|
||||||
|
|
||||||
if (dir_len && dir_name[dir_len-1] == '/')
|
if (dir_len && dir_name[dir_len-1] == '/')
|
||||||
sprintf (path, "%s%s", dir_name, de->d_name);
|
sprintf(path, "%s%s", dir_name, de->d_name);
|
||||||
else
|
else
|
||||||
sprintf (path, "%s/%s", dir_name, de->d_name);
|
sprintf(path, "%s/%s", dir_name, de->d_name);
|
||||||
if (LSTAT (path, &st) == -1)
|
if (LSTAT(path, &st) == -1)
|
||||||
perror (path);
|
bb_perror_msg(path);
|
||||||
else {
|
else {
|
||||||
if (de->d_name[0] != '.' || all) {
|
if (de->d_name[0] != '.' || (flags & OPT_ALL)) {
|
||||||
list_attributes (path);
|
list_attributes(path);
|
||||||
if (S_ISDIR(st.st_mode) && recursive &&
|
if (S_ISDIR(st.st_mode) && (flags & OPT_RECUR) &&
|
||||||
strcmp(de->d_name, ".") &&
|
strcmp(de->d_name, ".") &&
|
||||||
strcmp(de->d_name, "..")) {
|
strcmp(de->d_name, "..")) {
|
||||||
printf ("\n%s:\n", path);
|
printf("\n%s:\n", path);
|
||||||
iterate_on_dir (path, lsattr_dir_proc, NULL);
|
iterate_on_dir(path, lsattr_dir_proc, NULL);
|
||||||
printf ("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,55 +127,17 @@ static int lsattr_dir_proc (const char * dir_name, struct dirent * de,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lsattr_main (int argc, char ** argv)
|
int lsattr_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
flags = bb_getopt_ulflags(argc, argv, "Radlv");
|
||||||
setlocale(LC_MESSAGES, "");
|
|
||||||
setlocale(LC_CTYPE, "");
|
|
||||||
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
||||||
textdomain(NLS_CAT_NAME);
|
|
||||||
#endif
|
|
||||||
#if 0
|
|
||||||
if (argc && *argv)
|
|
||||||
program_name = *argv;
|
|
||||||
#endif
|
|
||||||
while ((c = getopt (argc, argv, "Radlv")) != EOF)
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 'R':
|
|
||||||
recursive = 1;
|
|
||||||
break;
|
|
||||||
case 'V':
|
|
||||||
verbose = 1;
|
|
||||||
break;
|
|
||||||
case 'a':
|
|
||||||
all = 1;
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
dirs_opt = 1;
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
pf_options = PFOPT_LONG;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
generation_opt = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (verbose)
|
|
||||||
fprintf (stderr, "lsattr %s (%s)\n",
|
|
||||||
E2FSPROGS_VERSION, E2FSPROGS_DATE);
|
|
||||||
#endif
|
|
||||||
if (optind > argc - 1)
|
if (optind > argc - 1)
|
||||||
lsattr_args (".");
|
lsattr_args(".");
|
||||||
else
|
else
|
||||||
for (i = optind; i < argc; i++)
|
for (i = optind; i < argc; i++)
|
||||||
lsattr_args (argv[i]);
|
lsattr_args(argv[i]);
|
||||||
exit(0);
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user