Yes. I already check it (toys/other/blkid.c). If just 2 files (blkid.c and stat.c) need human filesystem type, making common code in to lib is effective? And stat %T just need human filesystem type, but blkid should need more information per each type. If integration should be done, which structure can I follow?
2015-05-08 4:57 GMT+09:00 enh <[email protected]>: > there's already a list of fstypes in toys/other/blkid.c. it would probably > make more sense to move that into lib and share it. > > On Thu, May 7, 2015 at 3:59 AM, Hyejin Kim <[email protected]> wrote: > >> Hi. >> >> As need internally, added %T format to print filesystem type as human >> readable form. >> Plz, have a look. >> >> smackfs currently commented but will support later. >> >> >> >> diff --git a/toys/other/stat.c b/toys/other/stat.c >> index a96c1de..a9f4685 100644 >> --- a/toys/other/stat.c >> +++ b/toys/other/stat.c >> @@ -29,7 +29,7 @@ config STAT >> %a Available blocks |%b Total blocks |%c Total inodes >> %d Free inodes |%f Free blocks |%i File system ID >> %l Max filename length |%n File name |%s Fragment size >> - %S Best transfer size |%t File system type >> + %S Best transfer size |%t File system type |%T Type in human >> readable form >> */ >> >> #define FOR_stat >> @@ -46,6 +46,35 @@ GLOBALS( >> struct group *group_name; >> ) >> >> +static char* ftype_to_string(uint64_t ftype) >> +{ >> + switch (ftype) { >> + case 0xADFF: return "affs"; >> + case 0x5346544e: return "ntfs"; >> + case 0x1Cd1: return "devpts"; >> + case 0x137D: return "ext"; >> + case 0xEF51: return "ext2"; >> + case 0xEF53: return "ext2/ext3"; >> + case 0x1BADFACE: return "bfs"; >> + case 0x9123683E: return "btrfs"; >> + case 0x28cd3d45: return "cramfs"; >> + case 0x3153464a: return "jfs"; >> + case 0x7275: return "romfs"; >> + case 0x01021994: return "tmpfs"; >> + case 0x3434: return "nilfs"; >> + case 0x6969: return "nfs"; >> + case 0x9fa0: return "proc"; >> + case 0x534F434B: return "sockfs"; >> + case 0x62656572: return "sysfs"; >> + case 0x517B: return "smb"; >> + case 0x4d44: return "msdos"; >> + case 0x4006: return "fat"; >> + //case 0x43415d53: return "smackfs"; >> + case 0x73717368: return "squashfs"; >> + default: return "unknown"; >> + } >> +} >> + >> >> // Note: the atime, mtime, and ctime fields in struct stat are the start >> // of embedded struct timespec, but posix won't let them use that >> @@ -113,6 +142,7 @@ static void print_statfs(char type) { >> else if (type == 'f') xprintf("%llu", statfs->f_bfree); >> else if (type == 'l') xprintf("%ld", statfs->f_namelen); >> else if (type == 't') xprintf("%lx", statfs->f_type); >> + else if (type == 'T') xprintf("%s", ftype_to_string(statfs->f_type)); >> else if (type == 'i') >> xprintf("%08x%08x", statfs->f_fsid.__val[0], >> statfs->f_fsid.__val[1]); >> else if (type == 's') xprintf("%d", statfs->f_frsize); >> @@ -124,7 +154,7 @@ void stat_main(void) >> { >> int flagf = toys.optflags & FLAG_f; >> char *format = flagf >> - ? " File: \"%n\"\n ID: %i Namelen: %l Type: %t\n" >> + ? " File: \"%n\"\n ID: %i Namelen: %l Type: %T\n" >> "Block Size: %s Fundamental block size: %S\n" >> "Blocks: Total: %b\tFree: %f\tAvailable: %a\n" >> "Inodes: Total: %c\tFree: %d" >> -- >> >> _______________________________________________ >> Toybox mailing list >> [email protected] >> http://lists.landley.net/listinfo.cgi/toybox-landley.net >> >> > > > -- > Elliott Hughes - http://who/enh - http://jessies.org/~enh/ > Android native code/tools questions? Mail me/drop by/add me as a reviewer. >
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
