summaryrefslogtreecommitdiff
path: root/e2fsprogs
diff options
context:
space:
mode:
authorMike Frysinger2005-06-11 00:08:50 +0000
committerMike Frysinger2005-06-11 00:08:50 +0000
commit85cffcc83dfa8471c458789474513171ff9281df (patch)
tree6890b22c5a78b5166952d173a7d1a2bd94afca1b /e2fsprogs
parent942e137679ef3e07036cc32689ea7c802304cd1d (diff)
downloadbusybox-85cffcc83dfa8471c458789474513171ff9281df.zip
busybox-85cffcc83dfa8471c458789474513171ff9281df.tar.gz
recode functions to shrink size
Diffstat (limited to 'e2fsprogs')
-rw-r--r--e2fsprogs/e2p/e2p.h4
-rw-r--r--e2fsprogs/e2p/feature.c21
-rw-r--r--e2fsprogs/e2p/hashstr.c21
-rw-r--r--e2fsprogs/e2p/ls.c109
-rw-r--r--e2fsprogs/e2p/ostype.c14
-rw-r--r--e2fsprogs/e2p/pe.c22
-rw-r--r--e2fsprogs/e2p/pf.c1
-rw-r--r--e2fsprogs/e2p/ps.c7
-rw-r--r--e2fsprogs/e2p/uuid.c2
9 files changed, 92 insertions, 109 deletions
diff --git a/e2fsprogs/e2p/e2p.h b/e2fsprogs/e2p/e2p.h
index 78930ec..57bcec3 100644
--- a/e2fsprogs/e2p/e2p.h
+++ b/e2fsprogs/e2p/e2p.h
@@ -1,3 +1,4 @@
+#include "busybox.h"
#include <sys/types.h> /* Needed by dirent.h on netbsd */
#include <stdio.h>
#include <dirent.h>
@@ -30,8 +31,9 @@ int getversion (int fd, unsigned long * version);
int iterate_on_dir (const char * dir_name,
int (*func) (const char *, struct dirent *, void *),
void * private);
-void list_super(struct ext2_super_block * s);
+/*void list_super(struct ext2_super_block * s);*/
void list_super2(struct ext2_super_block * s, FILE *f);
+#define list_super(s) list_super2(s, stdout)
void print_fs_errors (FILE * f, unsigned short errors);
void print_flags (FILE * f, unsigned long flags, unsigned options);
void print_fs_state (FILE * f, unsigned short state);
diff --git a/e2fsprogs/e2p/feature.c b/e2fsprogs/e2p/feature.c
index ef11d93..f4e920a 100644
--- a/e2fsprogs/e2p/feature.c
+++ b/e2fsprogs/e2p/feature.c
@@ -56,10 +56,10 @@ static struct feature feature_list[] = {
const char *e2p_feature2string(int compat, unsigned int mask)
{
- struct feature *f;
+ struct feature *f;
static char buf[20];
- char fchar;
- int fnum;
+ char fchar;
+ int fnum;
for (f = feature_list; f->string; f++) {
if ((compat == f->compat) &&
@@ -67,7 +67,7 @@ const char *e2p_feature2string(int compat, unsigned int mask)
return f->string;
}
switch (compat) {
- case E2P_FEATURE_COMPAT:
+ case E2P_FEATURE_COMPAT:
fchar = 'C';
break;
case E2P_FEATURE_INCOMPAT:
@@ -81,15 +81,15 @@ const char *e2p_feature2string(int compat, unsigned int mask)
break;
}
for (fnum = 0; mask >>= 1; fnum++);
- sprintf(buf, "FEATURE_%c%d", fchar, fnum);
+ sprintf(buf, "FEATURE_%c%d", fchar, fnum);
return buf;
}
int e2p_string2feature(char *string, int *compat_type, unsigned int *mask)
{
- struct feature *f;
- char *eptr;
- int num;
+ struct feature *f;
+ char *eptr;
+ int num;
for (f = feature_list; f->string; f++) {
if (!strcasecmp(string, f->string)) {
@@ -128,14 +128,14 @@ int e2p_string2feature(char *string, int *compat_type, unsigned int *mask)
return 0;
}
-static char *skip_over_blanks(char *cp)
+static inline char *skip_over_blanks(char *cp)
{
while (*cp && isspace(*cp))
cp++;
return cp;
}
-static char *skip_over_word(char *cp)
+static inline char *skip_over_word(char *cp)
{
while (*cp && !isspace(*cp) && *cp != ',')
cp++;
@@ -187,4 +187,3 @@ int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
}
return 0;
}
-
diff --git a/e2fsprogs/e2p/hashstr.c b/e2fsprogs/e2p/hashstr.c
index b257eb2..7c0552f 100644
--- a/e2fsprogs/e2p/hashstr.c
+++ b/e2fsprogs/e2p/hashstr.c
@@ -17,20 +17,20 @@
#include "e2p.h"
struct hash {
- int num;
- const char *string;
+ int num;
+ const char *string;
};
static struct hash hash_list[] = {
- { EXT2_HASH_LEGACY, "legacy" },
- { EXT2_HASH_HALF_MD4, "half_md4" },
- { EXT2_HASH_TEA, "tea" },
- { 0, 0 },
+ { EXT2_HASH_LEGACY, "legacy" },
+ { EXT2_HASH_HALF_MD4, "half_md4" },
+ { EXT2_HASH_TEA, "tea" },
+ { 0, 0 },
};
const char *e2p_hash2string(int num)
{
- struct hash *p;
+ struct hash *p;
static char buf[20];
for (p = hash_list; p->string; p++) {
@@ -46,9 +46,9 @@ const char *e2p_hash2string(int num)
*/
int e2p_string2hash(char *string)
{
- struct hash *p;
- char *eptr;
- int num;
+ struct hash *p;
+ char *eptr;
+ int num;
for (p = hash_list; p->string; p++) {
if (!strcasecmp(string, p->string)) {
@@ -67,4 +67,3 @@ int e2p_string2hash(char *string)
return -1;
return num;
}
-
diff --git a/e2fsprogs/e2p/ls.c b/e2fsprogs/e2p/ls.c
index e8d9d48..71f8f51 100644
--- a/e2fsprogs/e2p/ls.c
+++ b/e2fsprogs/e2p/ls.c
@@ -20,28 +20,18 @@
#include "e2p.h"
-static void print_user (unsigned short uid, FILE *f)
+static void print_user(unsigned short uid, FILE *f)
{
- struct passwd *pw;
-
- fprintf(f, "%u ", uid);
- pw = getpwuid (uid);
- if (pw == NULL)
- fprintf(f, "(user unknown)\n");
- else
- fprintf(f, "(user %s)\n", pw->pw_name);
+ struct passwd *pw = getpwuid(uid);
+ fprintf(f, "%u (user %s)\n", uid,
+ (pw == NULL ? "unknown" : pw->pw_name));
}
-static void print_group (unsigned short gid, FILE *f)
+static void print_group(unsigned short gid, FILE *f)
{
- struct group *gr;
-
- fprintf(f, "%u ", gid);
- gr = getgrgid (gid);
- if (gr == NULL)
- fprintf(f, "(group unknown)\n");
- else
- fprintf(f, "(group %s)\n", gr->gr_name);
+ struct group *gr = getgrgid(gid);
+ fprintf(f, "%u (group %s)\n", gid,
+ (gr == NULL ? "unknown" : gr->gr_name));
}
#define MONTH_INT (86400 * 30)
@@ -167,10 +157,12 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
strncpy(buf, sb->s_last_mounted, sizeof(sb->s_last_mounted));
} else
strcpy(buf, "<not available>");
- fprintf(f, "Last mounted on: %s\n", buf);
- fprintf(f, "Filesystem UUID: %s\n", e2p_uuid2str(sb->s_uuid));
- fprintf(f, "Filesystem magic number: 0x%04X\n", sb->s_magic);
- fprintf(f, "Filesystem revision #: %d", sb->s_rev_level);
+ fprintf(f,
+ "Last mounted on: %s\n"
+ "Filesystem UUID: %s\n"
+ "Filesystem magic number: 0x%04X\n"
+ "Filesystem revision #: %d",
+ buf, e2p_uuid2str(sb->s_uuid), sb->s_magic, sb->s_rev_level);
if (sb->s_rev_level == EXT2_GOOD_OLD_REV) {
fprintf(f, " (original)\n");
#ifdef EXT2_DYNAMIC_REV
@@ -183,28 +175,34 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
print_mntopts(sb, f);
fprintf(f, "Filesystem state: ");
print_fs_state (f, sb->s_state);
- fprintf(f, "\n");
- fprintf(f, "Errors behavior: ");
+ fprintf(f, "\nErrors behavior: ");
print_fs_errors(f, sb->s_errors);
- fprintf(f, "\n");
str = e2p_os2string(sb->s_creator_os);
- fprintf(f, "Filesystem OS type: %s\n", str);
+ fprintf(f,
+ "\n"
+ "Filesystem OS type: %s\n"
+ "Inode count: %u\n"
+ "Block count: %u\n"
+ "Reserved block count: %u\n"
+ "Free blocks: %u\n"
+ "Free inodes: %u\n"
+ "First block: %u\n"
+ "Block size: %u\n"
+ "Fragment size: %u\n",
+ str, sb->s_inodes_count, sb->s_blocks_count, sb->s_r_blocks_count,
+ sb->s_free_blocks_count, sb->s_free_inodes_count,
+ sb->s_first_data_block, EXT2_BLOCK_SIZE(sb), EXT2_FRAG_SIZE(sb));
free(str);
- fprintf(f, "Inode count: %u\n", sb->s_inodes_count);
- fprintf(f, "Block count: %u\n", sb->s_blocks_count);
- fprintf(f, "Reserved block count: %u\n", sb->s_r_blocks_count);
- fprintf(f, "Free blocks: %u\n", sb->s_free_blocks_count);
- fprintf(f, "Free inodes: %u\n", sb->s_free_inodes_count);
- fprintf(f, "First block: %u\n", sb->s_first_data_block);
- fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb));
- fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb));
if (sb->s_reserved_gdt_blocks)
fprintf(f, "Reserved GDT blocks: %u\n",
sb->s_reserved_gdt_blocks);
- fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group);
- fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group);
- fprintf(f, "Inodes per group: %u\n", sb->s_inodes_per_group);
- fprintf(f, "Inode blocks per group: %u\n", inode_blocks_per_group);
+ fprintf(f,
+ "Blocks per group: %u\n"
+ "Fragments per group: %u\n"
+ "Inodes per group: %u\n"
+ "Inode blocks per group: %u\n",
+ sb->s_blocks_per_group, sb->s_frags_per_group,
+ sb->s_inodes_per_group, inode_blocks_per_group);
if (sb->s_first_meta_bg)
fprintf(f, "First meta block group: %u\n",
sb->s_first_meta_bg);
@@ -216,13 +214,17 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
fprintf(f, "Last mount time: %s",
sb->s_mtime ? ctime(&tm) : "n/a\n");
tm = sb->s_wtime;
- fprintf(f, "Last write time: %s", ctime(&tm));
- fprintf(f, "Mount count: %u\n", sb->s_mnt_count);
- fprintf(f, "Maximum mount count: %d\n", sb->s_max_mnt_count);
+ fprintf(f,
+ "Last write time: %s"
+ "Mount count: %u\n"
+ "Maximum mount count: %d\n",
+ ctime(&tm), sb->s_mnt_count, sb->s_max_mnt_count);
tm = sb->s_lastcheck;
- fprintf(f, "Last checked: %s", ctime(&tm));
- fprintf(f, "Check interval: %u (%s)\n", sb->s_checkinterval,
- interval_string(sb->s_checkinterval));
+ fprintf(f,
+ "Last checked: %s"
+ "Check interval: %u (%s)\n",
+ ctime(&tm),
+ sb->s_checkinterval, interval_string(sb->s_checkinterval));
if (sb->s_checkinterval)
{
time_t next;
@@ -235,8 +237,10 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
fprintf(f, "Reserved blocks gid: ");
print_group(sb->s_def_resgid, f);
if (sb->s_rev_level >= EXT2_DYNAMIC_REV) {
- fprintf(f, "First inode: %d\n", sb->s_first_ino);
- fprintf(f, "Inode size: %d\n", sb->s_inode_size);
+ fprintf(f,
+ "First inode: %d\n"
+ "Inode size: %d\n",
+ sb->s_first_ino, sb->s_inode_size);
}
if (!e2p_is_null_uuid(sb->s_journal_uuid))
fprintf(f, "Journal UUID: %s\n",
@@ -259,18 +263,9 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
e2p_uuid2str(sb->s_hash_seed));
if (sb->s_jnl_backup_type) {
fprintf(f, "Journal backup: ");
- switch (sb->s_jnl_backup_type) {
- case 1:
+ if (sb->s_jnl_backup_type == 1)
fprintf(f, "inode blocks\n");
- break;
- default:
+ else
fprintf(f, "type %u\n", sb->s_jnl_backup_type);
- }
}
}
-
-void list_super (struct ext2_super_block * s)
-{
- list_super2(s, stdout);
-}
-
diff --git a/e2fsprogs/e2p/ostype.c b/e2fsprogs/e2p/ostype.c
index fe6597d..a079b57 100644
--- a/e2fsprogs/e2p/ostype.c
+++ b/e2fsprogs/e2p/ostype.c
@@ -23,17 +23,17 @@ const char *os_tab[] =
*/
char *e2p_os2string(int os_type)
{
- const char *os;
- char *ret;
+ const char *os;
+ char *ret;
if (os_type <= EXT2_OS_LITES)
os = os_tab[os_type];
else
os = "(unknown os)";
- ret = malloc(strlen(os)+1);
- strcpy(ret, os);
- return ret;
+ ret = xmalloc(strlen(os)+1);
+ strcpy(ret, os);
+ return ret;
}
/*
@@ -41,8 +41,8 @@ char *e2p_os2string(int os_type)
*/
int e2p_string2os(char *str)
{
- const char **cpp;
- int i = 0;
+ const char **cpp;
+ int i = 0;
for (cpp = os_tab; *cpp; cpp++, i++) {
if (!strcasecmp(str, *cpp))
diff --git a/e2fsprogs/e2p/pe.c b/e2fsprogs/e2p/pe.c
index 4cce691..07fb886 100644
--- a/e2fsprogs/e2p/pe.c
+++ b/e2fsprogs/e2p/pe.c
@@ -18,20 +18,14 @@
#include "e2p.h"
-void print_fs_errors (FILE * f, unsigned short errors)
+void print_fs_errors(FILE *f, unsigned short errors)
{
- switch (errors)
- {
- case EXT2_ERRORS_CONTINUE:
- fprintf (f, "Continue");
- break;
- case EXT2_ERRORS_RO:
- fprintf (f, "Remount read-only");
- break;
- case EXT2_ERRORS_PANIC:
- fprintf (f, "Panic");
- break;
- default:
- fprintf (f, "Unknown (continue)");
+ char *disp = NULL;
+ switch (errors) {
+ case EXT2_ERRORS_CONTINUE: disp = "Continue"; break;
+ case EXT2_ERRORS_RO: disp = "Remount read-only"; break;
+ case EXT2_ERRORS_PANIC: disp = "Panic"; break;
+ default: disp = "Unknown (continue)";
}
+ fprintf(f, disp);
}
diff --git a/e2fsprogs/e2p/pf.c b/e2fsprogs/e2p/pf.c
index 48d75a9..d1a1c4c 100644
--- a/e2fsprogs/e2p/pf.c
+++ b/e2fsprogs/e2p/pf.c
@@ -71,4 +71,3 @@ void print_flags (FILE * f, unsigned long flags, unsigned options)
if (long_opt && first)
fputs("---", f);
}
-
diff --git a/e2fsprogs/e2p/ps.c b/e2fsprogs/e2p/ps.c
index bec8b41..b7c0ee2 100644
--- a/e2fsprogs/e2p/ps.c
+++ b/e2fsprogs/e2p/ps.c
@@ -18,12 +18,9 @@
#include "e2p.h"
-void print_fs_state (FILE * f, unsigned short state)
+void print_fs_state(FILE *f, unsigned short state)
{
- if (state & EXT2_VALID_FS)
- fprintf (f, " clean");
- else
- fprintf (f, " not clean");
+ fprintf(f, (state & EXT2_VALID_FS ? " clean" : " not clean"));
if (state & EXT2_ERROR_FS)
fprintf (f, " with errors");
}
diff --git a/e2fsprogs/e2p/uuid.c b/e2fsprogs/e2p/uuid.c
index fef3b91..c16a768 100644
--- a/e2fsprogs/e2p/uuid.c
+++ b/e2fsprogs/e2p/uuid.c
@@ -70,10 +70,8 @@ void e2p_uuid_to_str(void *uu, char *out)
const char *e2p_uuid2str(void *uu)
{
static char buf[80];
-
if (e2p_is_null_uuid(uu))
return "<none>";
e2p_uuid_to_str(uu, buf);
return buf;
}
-