2006-12-26 07:00:59 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
|
|
|
* See README for additional information
|
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
2006-12-26 07:00:59 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libbb.h"
|
|
|
|
#include "e2fs_lib.h"
|
|
|
|
|
|
|
|
#if INT_MAX == LONG_MAX
|
2007-04-15 17:18:27 +05:30
|
|
|
#define IF_LONG_IS_SAME(...) __VA_ARGS__
|
|
|
|
#define IF_LONG_IS_WIDER(...)
|
2006-12-26 07:00:59 +05:30
|
|
|
#else
|
2007-04-15 17:18:27 +05:30
|
|
|
#define IF_LONG_IS_SAME(...)
|
|
|
|
#define IF_LONG_IS_WIDER(...) __VA_ARGS__
|
2006-12-26 07:00:59 +05:30
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Iterate a function on each entry of a directory */
|
|
|
|
int iterate_on_dir(const char *dir_name,
|
2009-06-05 15:36:05 +05:30
|
|
|
int FAST_FUNC (*func)(const char *, struct dirent *, void *),
|
|
|
|
void *private)
|
2006-12-26 07:00:59 +05:30
|
|
|
{
|
|
|
|
DIR *dir;
|
2009-06-05 15:36:05 +05:30
|
|
|
struct dirent *de;
|
2006-12-26 07:00:59 +05:30
|
|
|
|
|
|
|
dir = opendir(dir_name);
|
|
|
|
if (dir == NULL) {
|
|
|
|
return -1;
|
|
|
|
}
|
2009-06-05 15:36:05 +05:30
|
|
|
while ((de = readdir(dir)) != NULL) {
|
2006-12-26 07:00:59 +05:30
|
|
|
func(dir_name, de, private);
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print file attributes on an ext2 file system */
|
2020-11-30 17:33:03 +05:30
|
|
|
const uint32_t e2attr_flags_value[] ALIGN4 = {
|
2007-10-31 01:06:07 +05:30
|
|
|
#ifdef ENABLE_COMPRESSION
|
|
|
|
EXT2_COMPRBLK_FL,
|
|
|
|
EXT2_DIRTY_FL,
|
|
|
|
EXT2_NOCOMPR_FL,
|
|
|
|
#endif
|
|
|
|
EXT2_SECRM_FL,
|
|
|
|
EXT2_UNRM_FL,
|
|
|
|
EXT2_SYNC_FL,
|
|
|
|
EXT2_DIRSYNC_FL,
|
|
|
|
EXT2_IMMUTABLE_FL,
|
|
|
|
EXT2_APPEND_FL,
|
|
|
|
EXT2_NODUMP_FL,
|
|
|
|
EXT2_NOATIME_FL,
|
|
|
|
EXT2_COMPR_FL,
|
2021-06-20 16:04:05 +05:30
|
|
|
EXT2_ECOMPR_FL,
|
2007-10-31 01:06:07 +05:30
|
|
|
EXT3_JOURNAL_DATA_FL,
|
2021-06-20 16:04:05 +05:30
|
|
|
EXT2_INDEX_FL,
|
2007-10-31 01:06:07 +05:30
|
|
|
EXT2_NOTAIL_FL,
|
2021-06-20 16:04:05 +05:30
|
|
|
EXT2_TOPDIR_FL,
|
|
|
|
EXT2_EXTENT_FL,
|
|
|
|
EXT2_NOCOW_FL,
|
|
|
|
EXT2_CASEFOLD_FL,
|
|
|
|
EXT2_INLINE_DATA_FL,
|
|
|
|
EXT2_PROJINHERIT_FL,
|
|
|
|
EXT2_VERITY_FL,
|
2006-12-26 07:00:59 +05:30
|
|
|
};
|
|
|
|
|
2016-04-22 21:39:21 +05:30
|
|
|
const char e2attr_flags_sname[] ALIGN1 =
|
2006-12-26 07:00:59 +05:30
|
|
|
#ifdef ENABLE_COMPRESSION
|
2021-06-20 16:04:05 +05:30
|
|
|
"BZX"
|
2006-12-26 07:00:59 +05:30
|
|
|
#endif
|
2021-06-20 16:04:05 +05:30
|
|
|
"suSDiadAcEjItTeCFNPV";
|
2007-10-31 01:06:07 +05:30
|
|
|
|
2016-04-22 21:39:21 +05:30
|
|
|
static const char e2attr_flags_lname[] ALIGN1 =
|
2007-10-31 01:06:07 +05:30
|
|
|
#ifdef ENABLE_COMPRESSION
|
|
|
|
"Compressed_File" "\0"
|
|
|
|
"Compressed_Dirty_File" "\0"
|
|
|
|
"Compression_Raw_Access" "\0"
|
|
|
|
#endif
|
|
|
|
"Secure_Deletion" "\0"
|
|
|
|
"Undelete" "\0"
|
|
|
|
"Synchronous_Updates" "\0"
|
|
|
|
"Synchronous_Directory_Updates" "\0"
|
|
|
|
"Immutable" "\0"
|
|
|
|
"Append_Only" "\0"
|
|
|
|
"No_Dump" "\0"
|
|
|
|
"No_Atime" "\0"
|
|
|
|
"Compression_Requested" "\0"
|
2021-06-20 16:04:05 +05:30
|
|
|
"Encrypted" "\0"
|
2007-10-31 01:06:07 +05:30
|
|
|
"Journaled_Data" "\0"
|
2021-06-20 16:04:05 +05:30
|
|
|
"Indexed_directory" "\0"
|
2007-10-31 01:06:07 +05:30
|
|
|
"No_Tailmerging" "\0"
|
|
|
|
"Top_of_Directory_Hierarchies" "\0"
|
2021-06-20 16:04:05 +05:30
|
|
|
"Extents" "\0"
|
|
|
|
"No_COW" "\0"
|
|
|
|
"Casefold" "\0"
|
|
|
|
"Inline_Data" "\0"
|
|
|
|
"Project_Hierarchy" "\0"
|
|
|
|
"Verity" "\0"
|
2007-10-31 01:06:07 +05:30
|
|
|
/* Another trailing NUL is added by compiler */;
|
2006-12-26 07:00:59 +05:30
|
|
|
|
2021-06-23 16:15:51 +05:30
|
|
|
void print_e2flags(FILE *f, unsigned flags, unsigned options)
|
2006-12-26 07:00:59 +05:30
|
|
|
{
|
2007-10-31 01:06:07 +05:30
|
|
|
const uint32_t *fv;
|
|
|
|
const char *fn;
|
2006-12-26 07:00:59 +05:30
|
|
|
|
2007-10-31 01:06:07 +05:30
|
|
|
fv = e2attr_flags_value;
|
2006-12-26 07:00:59 +05:30
|
|
|
if (options & PFOPT_LONG) {
|
|
|
|
int first = 1;
|
2007-10-31 01:06:07 +05:30
|
|
|
fn = e2attr_flags_lname;
|
|
|
|
do {
|
|
|
|
if (flags & *fv) {
|
2006-12-26 07:00:59 +05:30
|
|
|
if (!first)
|
|
|
|
fputs(", ", f);
|
2007-10-31 01:06:07 +05:30
|
|
|
fputs(fn, f);
|
2006-12-26 07:00:59 +05:30
|
|
|
first = 0;
|
|
|
|
}
|
2007-10-31 01:06:07 +05:30
|
|
|
fv++;
|
|
|
|
fn += strlen(fn) + 1;
|
|
|
|
} while (*fn);
|
2006-12-26 07:00:59 +05:30
|
|
|
if (first)
|
|
|
|
fputs("---", f);
|
|
|
|
} else {
|
2007-10-31 01:06:07 +05:30
|
|
|
fn = e2attr_flags_sname;
|
|
|
|
do {
|
2006-12-26 08:32:25 +05:30
|
|
|
char c = '-';
|
2007-10-31 01:06:07 +05:30
|
|
|
if (flags & *fv)
|
|
|
|
c = *fn;
|
2006-12-26 08:32:25 +05:30
|
|
|
fputc(c, f);
|
2007-10-31 01:06:07 +05:30
|
|
|
fv++;
|
|
|
|
fn++;
|
|
|
|
} while (*fn);
|
2006-12-26 07:00:59 +05:30
|
|
|
}
|
|
|
|
}
|