Whamcloud - gitweb
LU-14712 e2fsprogs: support EXT2_FLAG_BG_TRIMMED and EXT2_FLAGS_TRACK_TRIM
[tools/e2fsprogs.git] / lib / e2p / ls.c
index 740bc8d..b40929c 100644 (file)
@@ -162,6 +162,14 @@ static void print_super_flags(struct ext2_super_block * s, FILE *f)
                fputs("test_filesystem ", f);
                flags_found++;
        }
+       if (s->s_flags & EXT2_FLAGS_TRACK_TRIM) {
+               fputs("track_trim ", f);
+               flags_found++;
+       }
+       if (s->s_flags & EXT2_FLAGS_HAS_IOPS) {
+               fputs("iops ", f);
+               flags_found++;
+       }
        if (flags_found)
                fputs("\n", f);
        else
@@ -269,12 +277,15 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
        fprintf(f, "Filesystem OS type:       %s\n", str);
        free(str);
        fprintf(f, "Inode count:              %u\n", sb->s_inodes_count);
-       fprintf(f, "Block count:              %llu\n", e2p_blocks_count(sb));
-       fprintf(f, "Reserved block count:     %llu\n", e2p_r_blocks_count(sb));
+       fprintf(f, "Block count:              %llu\n",
+               (unsigned long long) e2p_blocks_count(sb));
+       fprintf(f, "Reserved block count:     %llu\n",
+               (unsigned long long) e2p_r_blocks_count(sb));
        if (sb->s_overhead_clusters)
                fprintf(f, "Overhead clusters:        %u\n",
                        sb->s_overhead_clusters);
-       fprintf(f, "Free blocks:              %llu\n", e2p_free_blocks_count(sb));
+       fprintf(f, "Free blocks:              %llu\n",
+               (unsigned long long) e2p_free_blocks_count(sb));
        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));
@@ -309,45 +320,42 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
                        sb->s_first_meta_bg);
        if (sb->s_log_groups_per_flex)
                fprintf(f, "Flex block group size:    %u\n",
-                       1 << sb->s_log_groups_per_flex);
-       if (sb->s_mkfs_time) {
-               tm = sb->s_mkfs_time;
+                       1U << sb->s_log_groups_per_flex);
+       tm = ext2fs_get_tstamp(sb, s_mkfs_time);
+       if (tm)
                fprintf(f, "Filesystem created:       %s", ctime(&tm));
-       }
-       tm = sb->s_mtime;
-       fprintf(f, "Last mount time:          %s",
-               sb->s_mtime ? ctime(&tm) : "n/a\n");
-       tm = sb->s_wtime;
+       tm = ext2fs_get_tstamp(sb, s_mtime);
+       fprintf(f, "Last mount time:          %s", tm ? ctime(&tm) : "n/a\n");
+       tm = ext2fs_get_tstamp(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);
-       tm = sb->s_lastcheck;
+       tm = ext2fs_get_tstamp(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));
        if (sb->s_checkinterval)
        {
-               time_t next;
-
-               next = sb->s_lastcheck + sb->s_checkinterval;
-               fprintf(f, "Next check after:         %s", ctime(&next));
+               tm += sb->s_checkinterval;
+               fprintf(f, "Next check after:         %s", ctime(&tm));
        }
 #define POW2(x) ((__u64) 1 << (x))
        if (sb->s_kbytes_written) {
                fprintf(f, "Lifetime writes:          ");
                if (sb->s_kbytes_written < POW2(13))
-                       fprintf(f, "%llu kB\n", sb->s_kbytes_written);
+                       fprintf(f, "%llu kB\n",
+                               (unsigned long long) sb->s_kbytes_written);
                else if (sb->s_kbytes_written < POW2(23))
-                       fprintf(f, "%llu MB\n",
-                               (sb->s_kbytes_written + POW2(9)) >> 10);
+                 fprintf(f, "%llu MB\n", (unsigned long long)
+                         (sb->s_kbytes_written + POW2(9)) >> 10);
                else if (sb->s_kbytes_written < POW2(33))
-                       fprintf(f, "%llu GB\n",
+                 fprintf(f, "%llu GB\n", (unsigned long long)
                                (sb->s_kbytes_written + POW2(19)) >> 20);
                else if (sb->s_kbytes_written < POW2(43))
-                       fprintf(f, "%llu TB\n",
+                       fprintf(f, "%llu TB\n", (unsigned long long)
                                (sb->s_kbytes_written + POW2(29)) >> 30);
                else
-                       fprintf(f, "%llu PB\n",
+                       fprintf(f, "%llu PB\n", (unsigned long long)
                                (sb->s_kbytes_written + POW2(39)) >> 40);
        }
        fprintf(f, "Reserved blocks uid:      ");
@@ -356,7 +364,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
        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, "Inode size:               %d\n", sb->s_inode_size);
                if (sb->s_min_extra_isize)
                        fprintf(f, "Required extra isize:     %d\n",
                                sb->s_min_extra_isize);
@@ -371,7 +379,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
                fprintf(f, "Journal inode:            %u\n",
                        sb->s_journal_inum);
        if (sb->s_journal_dev)
-               fprintf(f, "Journal device:               0x%04x\n",
+               fprintf(f, "Journal device:           0x%04x\n",
                        sb->s_journal_dev);
        if (sb->s_last_orphan)
                fprintf(f, "First orphan inode:       %u\n",
@@ -407,7 +415,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
                fprintf(f, "Snapshot ID:              %u\n",
                        sb->s_snapshot_id);
                fprintf(f, "Snapshot reserved blocks: %llu\n",
-                       sb->s_snapshot_r_blocks_count);
+                       (unsigned long long) sb->s_snapshot_r_blocks_count);
        }
        if (sb->s_snapshot_list)
                fprintf(f, "Snapshot list head:       %u\n",
@@ -415,33 +423,43 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
        if (sb->s_error_count)
                fprintf(f, "FS Error count:           %u\n",
                        sb->s_error_count);
-       if (sb->s_first_error_time) {
-               tm = sb->s_first_error_time;
+       tm = ext2fs_get_tstamp(sb, s_first_error_time);
+       if (tm) {
                fprintf(f, "First error time:         %s", ctime(&tm));
                fprintf(f, "First error function:     %.*s\n",
                        EXT2_LEN_STR(sb->s_first_error_func));
                fprintf(f, "First error line #:       %u\n",
                        sb->s_first_error_line);
-               fprintf(f, "First error inode #:      %u\n",
-                       sb->s_first_error_ino);
-               fprintf(f, "First error block #:      %llu\n",
-                       sb->s_first_error_block);
+               if (sb->s_first_error_ino)
+                       fprintf(f, "First error inode #:      %u\n",
+                               sb->s_first_error_ino);
+               if (sb->s_first_error_block)
+                       fprintf(f, "First error block #:      %llu\n",
+                               (unsigned long long) sb->s_first_error_block);
+               if (sb->s_first_error_errcode)
+                       fprintf(f, "First error err:          %s\n",
+                               e2p_errcode2str(sb->s_first_error_errcode));
        }
-       if (sb->s_last_error_time) {
-               tm = sb->s_last_error_time;
+       tm = ext2fs_get_tstamp(sb, s_last_error_time);
+       if (tm) {
                fprintf(f, "Last error time:          %s", ctime(&tm));
                fprintf(f, "Last error function:      %.*s\n",
                        EXT2_LEN_STR(sb->s_last_error_func));
                fprintf(f, "Last error line #:        %u\n",
                        sb->s_last_error_line);
-               fprintf(f, "Last error inode #:       %u\n",
-                       sb->s_last_error_ino);
-               fprintf(f, "Last error block #:       %llu\n",
-                       sb->s_last_error_block);
+               if (sb->s_last_error_ino)
+                       fprintf(f, "Last error inode #:       %u\n",
+                               sb->s_last_error_ino);
+               if (sb->s_last_error_block)
+                       fprintf(f, "Last error block #:       %llu\n",
+                               (unsigned long long) sb->s_last_error_block);
+               if (sb->s_last_error_errcode)
+                       fprintf(f, "Last error err:           %s\n",
+                               e2p_errcode2str(sb->s_last_error_errcode));
        }
        if (ext2fs_has_feature_mmp(sb)) {
                fprintf(f, "MMP block number:         %llu\n",
-                       (long long)sb->s_mmp_block);
+                       (unsigned long long) sb->s_mmp_block);
                fprintf(f, "MMP update interval:      %u\n",
                        sb->s_mmp_update_interval);
        }
@@ -468,6 +486,9 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
        if (ext2fs_has_feature_casefold(sb))
                fprintf(f, "Character encoding:       %s\n",
                        e2p_encoding2str(sb->s_encoding));
+       if (ext2fs_has_feature_orphan_file(sb))
+               fprintf(f, "Orphan file inode:        %u\n",
+                       sb->s_orphan_file_inum);
 }
 
 void list_super (struct ext2_super_block * s)