blob: 78cd335ee149e54d836d04e6def77ce8ae59a9fb [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001/*
2 * ls.c - List the contents of an ext2fs superblock
3 *
4 * Copyright (C) 1992, 1993, 1994 Remy Card <card@masi.ibp.fr>
5 * Laboratoire MASI, Institut Blaise Pascal
6 * Universite Pierre et Marie Curie (Paris VI)
7 *
Theodore Ts'o21c84b71997-04-29 16:15:03 +00008 * Copyright (C) 1995, 1996, 1997 Theodore Ts'o <tytso@mit.edu>
Theodore Ts'oefc6f622008-08-27 23:07:54 -04009 *
Theodore Ts'o543547a2010-05-17 21:31:56 -040010 * %Begin-Header%
11 * This file may be redistributed under the terms of the GNU Library
12 * General Public License, version 2.
13 * %End-Header%
Theodore Ts'o3839e651997-04-26 13:21:57 +000014 */
15
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000016#include <stdio.h>
Theodore Ts'ob7e4eef2005-04-09 01:22:09 -040017#include <stdlib.h>
Theodore Ts'o50e1e101997-04-26 13:58:21 +000018#include <sys/types.h>
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000019#include <string.h>
Theodore Ts'of3db3561997-04-26 13:34:30 +000020#include <grp.h>
21#include <pwd.h>
Theodore Ts'o3839e651997-04-26 13:21:57 +000022#include <time.h>
23
Theodore Ts'o3839e651997-04-26 13:21:57 +000024#include "e2p.h"
25
Theodore Ts'o53d39552000-08-14 20:13:32 +000026static void print_user (unsigned short uid, FILE *f)
Theodore Ts'of3db3561997-04-26 13:34:30 +000027{
28 struct passwd *pw;
29
Theodore Ts'o53d39552000-08-14 20:13:32 +000030 fprintf(f, "%u ", uid);
Theodore Ts'of3db3561997-04-26 13:34:30 +000031 pw = getpwuid (uid);
32 if (pw == NULL)
Theodore Ts'o53d39552000-08-14 20:13:32 +000033 fprintf(f, "(user unknown)\n");
Theodore Ts'of3db3561997-04-26 13:34:30 +000034 else
Theodore Ts'o53d39552000-08-14 20:13:32 +000035 fprintf(f, "(user %s)\n", pw->pw_name);
Theodore Ts'of3db3561997-04-26 13:34:30 +000036}
37
Theodore Ts'o53d39552000-08-14 20:13:32 +000038static void print_group (unsigned short gid, FILE *f)
Theodore Ts'of3db3561997-04-26 13:34:30 +000039{
40 struct group *gr;
41
Theodore Ts'o53d39552000-08-14 20:13:32 +000042 fprintf(f, "%u ", gid);
Theodore Ts'of3db3561997-04-26 13:34:30 +000043 gr = getgrgid (gid);
44 if (gr == NULL)
Theodore Ts'o53d39552000-08-14 20:13:32 +000045 fprintf(f, "(group unknown)\n");
Theodore Ts'of3db3561997-04-26 13:34:30 +000046 else
Theodore Ts'o53d39552000-08-14 20:13:32 +000047 fprintf(f, "(group %s)\n", gr->gr_name);
Theodore Ts'of3db3561997-04-26 13:34:30 +000048}
49
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000050#define MONTH_INT (86400 * 30)
51#define WEEK_INT (86400 * 7)
52#define DAY_INT (86400)
53#define HOUR_INT (60 * 60)
54#define MINUTE_INT (60)
55
Theodore Ts'o21c84b71997-04-29 16:15:03 +000056static const char *interval_string(unsigned int secs)
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000057{
58 static char buf[256], tmp[80];
59 int hr, min, num;
60
61 buf[0] = 0;
62
Theodore Ts'o21c84b71997-04-29 16:15:03 +000063 if (secs == 0)
64 return "<none>";
65
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000066 if (secs >= MONTH_INT) {
67 num = secs / MONTH_INT;
68 secs -= num*MONTH_INT;
69 sprintf(buf, "%d month%s", num, (num>1) ? "s" : "");
70 }
71 if (secs >= WEEK_INT) {
72 num = secs / WEEK_INT;
73 secs -= num*WEEK_INT;
74 sprintf(tmp, "%s%d week%s", buf[0] ? ", " : "",
75 num, (num>1) ? "s" : "");
76 strcat(buf, tmp);
77 }
78 if (secs >= DAY_INT) {
79 num = secs / DAY_INT;
80 secs -= num*DAY_INT;
81 sprintf(tmp, "%s%d day%s", buf[0] ? ", " : "",
82 num, (num>1) ? "s" : "");
83 strcat(buf, tmp);
84 }
85 if (secs > 0) {
86 hr = secs / HOUR_INT;
87 secs -= hr*HOUR_INT;
88 min = secs / MINUTE_INT;
89 secs -= min*MINUTE_INT;
90 sprintf(tmp, "%s%d:%02d:%02d", buf[0] ? ", " : "",
91 hr, min, secs);
92 strcat(buf, tmp);
93 }
94 return buf;
95}
96
Theodore Ts'o53d39552000-08-14 20:13:32 +000097static void print_features(struct ext2_super_block * s, FILE *f)
Theodore Ts'od7b701d1999-09-14 20:17:38 +000098{
99#ifdef EXT2_DYNAMIC_REV
100 int i, j, printed=0;
101 __u32 *mask = &s->s_feature_compat, m;
102
Theodore Ts'o53d39552000-08-14 20:13:32 +0000103 fprintf(f, "Filesystem features: ");
Theodore Ts'od7b701d1999-09-14 20:17:38 +0000104 for (i=0; i <3; i++,mask++) {
105 for (j=0,m=1; j < 32; j++, m<<=1) {
106 if (*mask & m) {
Theodore Ts'o53d39552000-08-14 20:13:32 +0000107 fprintf(f, " %s", e2p_feature2string(i, m));
Theodore Ts'od7b701d1999-09-14 20:17:38 +0000108 printed++;
109 }
110 }
111 }
112 if (printed == 0)
Theodore Ts'o6d216212001-05-13 22:14:53 +0000113 fprintf(f, " (none)");
Theodore Ts'o53d39552000-08-14 20:13:32 +0000114 fprintf(f, "\n");
Theodore Ts'od7b701d1999-09-14 20:17:38 +0000115#endif
116}
117
Theodore Ts'oa0c3fd52002-10-15 17:43:43 -0400118static void print_mntopts(struct ext2_super_block * s, FILE *f)
119{
120#ifdef EXT2_DYNAMIC_REV
121 int i, printed=0;
122 __u32 mask = s->s_default_mount_opts, m;
123
124 fprintf(f, "Default mount options: ");
Theodore Ts'o4a959fe2002-10-20 01:52:52 -0400125 if (mask & EXT3_DEFM_JMODE) {
126 fprintf(f, " %s", e2p_mntopt2string(mask & EXT3_DEFM_JMODE));
127 printed++;
128 }
Theodore Ts'oa0c3fd52002-10-15 17:43:43 -0400129 for (i=0,m=1; i < 32; i++, m<<=1) {
Theodore Ts'o4a959fe2002-10-20 01:52:52 -0400130 if (m & EXT3_DEFM_JMODE)
131 continue;
Theodore Ts'oa0c3fd52002-10-15 17:43:43 -0400132 if (mask & m) {
Theodore Ts'o4a959fe2002-10-20 01:52:52 -0400133 fprintf(f, " %s", e2p_mntopt2string(m));
Theodore Ts'oa0c3fd52002-10-15 17:43:43 -0400134 printed++;
135 }
136 }
137 if (printed == 0)
138 fprintf(f, " (none)");
139 fprintf(f, "\n");
140#endif
141}
Theodore Ts'od7b701d1999-09-14 20:17:38 +0000142
Theodore Ts'of77704e2006-11-11 22:32:35 -0500143static void print_super_flags(struct ext2_super_block * s, FILE *f)
144{
145 int flags_found = 0;
146
147 if (s->s_flags == 0)
148 return;
149
150 fputs("Filesystem flags: ", f);
151 if (s->s_flags & EXT2_FLAGS_SIGNED_HASH) {
Theodore Ts'o6cb27402008-01-26 19:06:35 -0500152 fputs("signed_directory_hash ", f);
Theodore Ts'of77704e2006-11-11 22:32:35 -0500153 flags_found++;
154 }
155 if (s->s_flags & EXT2_FLAGS_UNSIGNED_HASH) {
Theodore Ts'o6cb27402008-01-26 19:06:35 -0500156 fputs("unsigned_directory_hash ", f);
157 flags_found++;
158 }
159 if (s->s_flags & EXT2_FLAGS_TEST_FILESYS) {
160 fputs("test_filesystem ", f);
Theodore Ts'of77704e2006-11-11 22:32:35 -0500161 flags_found++;
162 }
163 if (flags_found)
164 fputs("\n", f);
165 else
166 fputs("(none)\n", f);
167}
168
JP Abgralle0ed7402014-03-19 19:08:39 -0700169static __u64 e2p_blocks_count(struct ext2_super_block *super)
170{
171 return super->s_blocks_count |
172 (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
173 (__u64) super->s_blocks_count_hi << 32 : 0);
174}
175
176static __u64 e2p_r_blocks_count(struct ext2_super_block *super)
177{
178 return super->s_r_blocks_count |
179 (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
180 (__u64) super->s_r_blocks_count_hi << 32 : 0);
181}
182
183static __u64 e2p_free_blocks_count(struct ext2_super_block *super)
184{
185 return super->s_free_blocks_count |
186 (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
187 (__u64) super->s_free_blocks_hi << 32 : 0);
188}
Theodore Ts'o1e3472c1997-04-29 14:53:37 +0000189
Theodore Ts'o7f88b041997-04-26 14:48:50 +0000190#ifndef EXT2_INODE_SIZE
191#define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode)
192#endif
193
Theodore Ts'oa29f4d31997-04-29 21:26:48 +0000194#ifndef EXT2_GOOD_OLD_REV
195#define EXT2_GOOD_OLD_REV 0
196#endif
197
Theodore Ts'o379955f2001-01-01 15:54:58 +0000198void list_super2(struct ext2_super_block * sb, FILE *f)
Theodore Ts'o3839e651997-04-26 13:21:57 +0000199{
Theodore Ts'o7f88b041997-04-26 14:48:50 +0000200 int inode_blocks_per_group;
Theodore Ts'o63253942005-03-19 01:13:22 -0500201 char buf[80], *str;
Theodore Ts'o21c84b71997-04-29 16:15:03 +0000202 time_t tm;
Theodore Ts'o7f88b041997-04-26 14:48:50 +0000203
Theodore Ts'o379955f2001-01-01 15:54:58 +0000204 inode_blocks_per_group = (((sb->s_inodes_per_group *
205 EXT2_INODE_SIZE(sb)) +
206 EXT2_BLOCK_SIZE(sb) - 1) /
207 EXT2_BLOCK_SIZE(sb));
Theodore Ts'o1e3472c1997-04-29 14:53:37 +0000208 if (sb->s_volume_name[0]) {
209 memset(buf, 0, sizeof(buf));
210 strncpy(buf, sb->s_volume_name, sizeof(sb->s_volume_name));
Theodore Ts'o21c84b71997-04-29 16:15:03 +0000211 } else
212 strcpy(buf, "<none>");
Theodore Ts'o53d39552000-08-14 20:13:32 +0000213 fprintf(f, "Filesystem volume name: %s\n", buf);
Theodore Ts'o1e3472c1997-04-29 14:53:37 +0000214 if (sb->s_last_mounted[0]) {
215 memset(buf, 0, sizeof(buf));
216 strncpy(buf, sb->s_last_mounted, sizeof(sb->s_last_mounted));
Theodore Ts'o21c84b71997-04-29 16:15:03 +0000217 } else
218 strcpy(buf, "<not available>");
Theodore Ts'o53d39552000-08-14 20:13:32 +0000219 fprintf(f, "Last mounted on: %s\n", buf);
Theodore Ts'of61fc0b2002-08-24 00:04:03 -0400220 fprintf(f, "Filesystem UUID: %s\n", e2p_uuid2str(sb->s_uuid));
Theodore Ts'o379955f2001-01-01 15:54:58 +0000221 fprintf(f, "Filesystem magic number: 0x%04X\n", sb->s_magic);
222 fprintf(f, "Filesystem revision #: %d", sb->s_rev_level);
223 if (sb->s_rev_level == EXT2_GOOD_OLD_REV) {
Theodore Ts'o53d39552000-08-14 20:13:32 +0000224 fprintf(f, " (original)\n");
Theodore Ts'o521e3681997-04-29 17:48:10 +0000225#ifdef EXT2_DYNAMIC_REV
Theodore Ts'o379955f2001-01-01 15:54:58 +0000226 } else if (sb->s_rev_level == EXT2_DYNAMIC_REV) {
Theodore Ts'o53d39552000-08-14 20:13:32 +0000227 fprintf(f, " (dynamic)\n");
Theodore Ts'o521e3681997-04-29 17:48:10 +0000228#endif
229 } else
Theodore Ts'o6d216212001-05-13 22:14:53 +0000230 fprintf(f, " (unknown)\n");
Theodore Ts'o379955f2001-01-01 15:54:58 +0000231 print_features(sb, f);
Theodore Ts'of77704e2006-11-11 22:32:35 -0500232 print_super_flags(sb, f);
Theodore Ts'oa0c3fd52002-10-15 17:43:43 -0400233 print_mntopts(sb, f);
Theodore Ts'o9345f022010-09-18 19:38:22 -0400234 if (sb->s_mount_opts[0])
235 fprintf(f, "Mount options: %s\n", sb->s_mount_opts);
Theodore Ts'o53d39552000-08-14 20:13:32 +0000236 fprintf(f, "Filesystem state: ");
Theodore Ts'o379955f2001-01-01 15:54:58 +0000237 print_fs_state (f, sb->s_state);
Theodore Ts'o53d39552000-08-14 20:13:32 +0000238 fprintf(f, "\n");
239 fprintf(f, "Errors behavior: ");
Theodore Ts'o379955f2001-01-01 15:54:58 +0000240 print_fs_errors(f, sb->s_errors);
Theodore Ts'o53d39552000-08-14 20:13:32 +0000241 fprintf(f, "\n");
Theodore Ts'o63253942005-03-19 01:13:22 -0500242 str = e2p_os2string(sb->s_creator_os);
243 fprintf(f, "Filesystem OS type: %s\n", str);
244 free(str);
Theodore Ts'o379955f2001-01-01 15:54:58 +0000245 fprintf(f, "Inode count: %u\n", sb->s_inodes_count);
JP Abgralle0ed7402014-03-19 19:08:39 -0700246 fprintf(f, "Block count: %llu\n", e2p_blocks_count(sb));
247 fprintf(f, "Reserved block count: %llu\n", e2p_r_blocks_count(sb));
248 if (sb->s_overhead_blocks)
249 fprintf(f, "Overhead blocks: %u\n",
250 sb->s_overhead_blocks);
251 fprintf(f, "Free blocks: %llu\n", e2p_free_blocks_count(sb));
Theodore Ts'o379955f2001-01-01 15:54:58 +0000252 fprintf(f, "Free inodes: %u\n", sb->s_free_inodes_count);
253 fprintf(f, "First block: %u\n", sb->s_first_data_block);
254 fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb));
JP Abgralle0ed7402014-03-19 19:08:39 -0700255 if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC)
256 fprintf(f, "Cluster size: %u\n",
257 EXT2_CLUSTER_SIZE(sb));
258 else
259 fprintf(f, "Fragment size: %u\n",
260 EXT2_CLUSTER_SIZE(sb));
261 if (sb->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
262 fprintf(f, "Group descriptor size: %u\n", sb->s_desc_size);
Theodore Ts'ofaeaf932004-12-23 07:47:12 -0500263 if (sb->s_reserved_gdt_blocks)
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400264 fprintf(f, "Reserved GDT blocks: %u\n",
Theodore Ts'ofaeaf932004-12-23 07:47:12 -0500265 sb->s_reserved_gdt_blocks);
Theodore Ts'o379955f2001-01-01 15:54:58 +0000266 fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group);
JP Abgralle0ed7402014-03-19 19:08:39 -0700267 if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC)
268 fprintf(f, "Clusters per group: %u\n",
269 sb->s_clusters_per_group);
270 else
271 fprintf(f, "Fragments per group: %u\n",
272 sb->s_clusters_per_group);
Theodore Ts'o379955f2001-01-01 15:54:58 +0000273 fprintf(f, "Inodes per group: %u\n", sb->s_inodes_per_group);
Theodore Ts'o53d39552000-08-14 20:13:32 +0000274 fprintf(f, "Inode blocks per group: %u\n", inode_blocks_per_group);
Theodore Ts'o6b226c32008-02-18 22:59:42 -0500275 if (sb->s_raid_stride)
Theodore Ts'o395529b2008-02-22 16:52:27 -0500276 fprintf(f, "RAID stride: %u\n",
Theodore Ts'o6b226c32008-02-18 22:59:42 -0500277 sb->s_raid_stride);
278 if (sb->s_raid_stripe_width)
Theodore Ts'o395529b2008-02-22 16:52:27 -0500279 fprintf(f, "RAID stripe width: %u\n",
Theodore Ts'o6b226c32008-02-18 22:59:42 -0500280 sb->s_raid_stripe_width);
Theodore Ts'oc046ac72002-10-20 00:38:57 -0400281 if (sb->s_first_meta_bg)
282 fprintf(f, "First meta block group: %u\n",
283 sb->s_first_meta_bg);
Theodore Ts'o494a1da2008-04-22 07:47:25 -0400284 if (sb->s_log_groups_per_flex)
285 fprintf(f, "Flex block group size: %u\n",
286 1 << sb->s_log_groups_per_flex);
Theodore Ts'o9d2aefb2002-10-25 17:29:55 -0400287 if (sb->s_mkfs_time) {
288 tm = sb->s_mkfs_time;
289 fprintf(f, "Filesystem created: %s", ctime(&tm));
290 }
291 tm = sb->s_mtime;
292 fprintf(f, "Last mount time: %s",
293 sb->s_mtime ? ctime(&tm) : "n/a\n");
Theodore Ts'o379955f2001-01-01 15:54:58 +0000294 tm = sb->s_wtime;
Theodore Ts'o53d39552000-08-14 20:13:32 +0000295 fprintf(f, "Last write time: %s", ctime(&tm));
Theodore Ts'o379955f2001-01-01 15:54:58 +0000296 fprintf(f, "Mount count: %u\n", sb->s_mnt_count);
297 fprintf(f, "Maximum mount count: %d\n", sb->s_max_mnt_count);
298 tm = sb->s_lastcheck;
Theodore Ts'o53d39552000-08-14 20:13:32 +0000299 fprintf(f, "Last checked: %s", ctime(&tm));
Theodore Ts'o379955f2001-01-01 15:54:58 +0000300 fprintf(f, "Check interval: %u (%s)\n", sb->s_checkinterval,
301 interval_string(sb->s_checkinterval));
302 if (sb->s_checkinterval)
Theodore Ts'o3839e651997-04-26 13:21:57 +0000303 {
304 time_t next;
305
Theodore Ts'o379955f2001-01-01 15:54:58 +0000306 next = sb->s_lastcheck + sb->s_checkinterval;
Theodore Ts'o53d39552000-08-14 20:13:32 +0000307 fprintf(f, "Next check after: %s", ctime(&next));
Theodore Ts'o3839e651997-04-26 13:21:57 +0000308 }
Theodore Ts'ob7c5b402009-03-05 19:40:20 -0500309#define POW2(x) ((__u64) 1 << (x))
310 if (sb->s_kbytes_written) {
311 fprintf(f, "Lifetime writes: ");
312 if (sb->s_kbytes_written < POW2(13))
313 fprintf(f, "%llu kB\n", sb->s_kbytes_written);
314 else if (sb->s_kbytes_written < POW2(23))
315 fprintf(f, "%llu MB\n",
316 (sb->s_kbytes_written + POW2(9)) >> 10);
317 else if (sb->s_kbytes_written < POW2(33))
318 fprintf(f, "%llu GB\n",
319 (sb->s_kbytes_written + POW2(19)) >> 20);
320 else if (sb->s_kbytes_written < POW2(43))
321 fprintf(f, "%llu TB\n",
322 (sb->s_kbytes_written + POW2(29)) >> 30);
323 else
324 fprintf(f, "%llu PB\n",
325 (sb->s_kbytes_written + POW2(39)) >> 40);
326 }
Theodore Ts'o53d39552000-08-14 20:13:32 +0000327 fprintf(f, "Reserved blocks uid: ");
Theodore Ts'o379955f2001-01-01 15:54:58 +0000328 print_user(sb->s_def_resuid, f);
Theodore Ts'o53d39552000-08-14 20:13:32 +0000329 fprintf(f, "Reserved blocks gid: ");
Theodore Ts'o379955f2001-01-01 15:54:58 +0000330 print_group(sb->s_def_resgid, f);
331 if (sb->s_rev_level >= EXT2_DYNAMIC_REV) {
332 fprintf(f, "First inode: %d\n", sb->s_first_ino);
Theodore Ts'o41a5afa2008-04-20 16:10:07 -0400333 fprintf(f, "Inode size: %d\n", sb->s_inode_size);
334 if (sb->s_min_extra_isize)
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400335 fprintf(f, "Required extra isize: %d\n",
Theodore Ts'o41a5afa2008-04-20 16:10:07 -0400336 sb->s_min_extra_isize);
337 if (sb->s_want_extra_isize)
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400338 fprintf(f, "Desired extra isize: %d\n",
Theodore Ts'o41a5afa2008-04-20 16:10:07 -0400339 sb->s_want_extra_isize);
Theodore Ts'o7f88b041997-04-26 14:48:50 +0000340 }
Theodore Ts'o9522e0a2003-03-17 13:53:38 -0500341 if (!e2p_is_null_uuid(sb->s_journal_uuid))
Theodore Ts'of61fc0b2002-08-24 00:04:03 -0400342 fprintf(f, "Journal UUID: %s\n",
343 e2p_uuid2str(sb->s_journal_uuid));
Theodore Ts'o9522e0a2003-03-17 13:53:38 -0500344 if (sb->s_journal_inum)
345 fprintf(f, "Journal inode: %u\n",
346 sb->s_journal_inum);
347 if (sb->s_journal_dev)
348 fprintf(f, "Journal device: 0x%04x\n",
349 sb->s_journal_dev);
350 if (sb->s_last_orphan)
351 fprintf(f, "First orphan inode: %u\n",
352 sb->s_last_orphan);
353 if ((sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) ||
354 sb->s_def_hash_version)
Theodore Ts'of61fc0b2002-08-24 00:04:03 -0400355 fprintf(f, "Default directory hash: %s\n",
356 e2p_hash2string(sb->s_def_hash_version));
Theodore Ts'o9522e0a2003-03-17 13:53:38 -0500357 if (!e2p_is_null_uuid(sb->s_hash_seed))
Theodore Ts'of61fc0b2002-08-24 00:04:03 -0400358 fprintf(f, "Directory Hash Seed: %s\n",
359 e2p_uuid2str(sb->s_hash_seed));
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400360 if (sb->s_jnl_backup_type) {
361 fprintf(f, "Journal backup: ");
362 switch (sb->s_jnl_backup_type) {
363 case 1:
364 fprintf(f, "inode blocks\n");
365 break;
366 default:
367 fprintf(f, "type %u\n", sb->s_jnl_backup_type);
368 }
369 }
Theodore Ts'of5448c12010-06-24 21:08:37 -0400370 if (sb->s_snapshot_inum) {
371 fprintf(f, "Snapshot inode: %u\n",
372 sb->s_snapshot_inum);
373 fprintf(f, "Snapshot ID: %u\n",
374 sb->s_snapshot_id);
375 fprintf(f, "Snapshot reserved blocks: %llu\n",
376 sb->s_snapshot_r_blocks_count);
377 }
378 if (sb->s_snapshot_list)
379 fprintf(f, "Snapshot list head: %u\n",
380 sb->s_snapshot_list);
Theodore Ts'o993988f2010-06-25 10:53:13 -0400381 if (sb->s_error_count)
382 fprintf(f, "FS Error count: %u\n",
383 sb->s_error_count);
384 if (sb->s_first_error_time) {
385 tm = sb->s_first_error_time;
386 fprintf(f, "First error time: %s", ctime(&tm));
387 memset(buf, 0, sizeof(buf));
JP Abgralle0ed7402014-03-19 19:08:39 -0700388 strncpy(buf, (char *)sb->s_first_error_func,
Theodore Ts'o993988f2010-06-25 10:53:13 -0400389 sizeof(sb->s_first_error_func));
390 fprintf(f, "First error function: %s\n", buf);
391 fprintf(f, "First error line #: %u\n",
392 sb->s_first_error_line);
393 fprintf(f, "First error inode #: %u\n",
394 sb->s_first_error_ino);
395 fprintf(f, "First error block #: %llu\n",
396 sb->s_first_error_block);
397 }
398 if (sb->s_last_error_time) {
399 tm = sb->s_last_error_time;
400 fprintf(f, "Last error time: %s", ctime(&tm));
401 memset(buf, 0, sizeof(buf));
JP Abgralle0ed7402014-03-19 19:08:39 -0700402 strncpy(buf, (char *)sb->s_last_error_func,
Theodore Ts'o993988f2010-06-25 10:53:13 -0400403 sizeof(sb->s_last_error_func));
404 fprintf(f, "Last error function: %s\n", buf);
405 fprintf(f, "Last error line #: %u\n",
406 sb->s_last_error_line);
407 fprintf(f, "Last error inode #: %u\n",
408 sb->s_last_error_ino);
409 fprintf(f, "Last error block #: %llu\n",
410 sb->s_last_error_block);
411 }
JP Abgralle0ed7402014-03-19 19:08:39 -0700412 if (sb->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) {
413 fprintf(f, "MMP block number: %llu\n",
414 (long long)sb->s_mmp_block);
415 fprintf(f, "MMP update interval: %u\n",
416 sb->s_mmp_update_interval);
417 }
418 if (sb->s_usr_quota_inum)
419 fprintf(f, "User quota inode: %u\n",
420 sb->s_usr_quota_inum);
421 if (sb->s_grp_quota_inum)
422 fprintf(f, "Group quota inode: %u\n",
423 sb->s_grp_quota_inum);
424
425 if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
426 fprintf(f, "Checksum: 0x%08x\n",
427 sb->s_checksum);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000428}
Theodore Ts'o1e3472c1997-04-29 14:53:37 +0000429
Theodore Ts'o53d39552000-08-14 20:13:32 +0000430void list_super (struct ext2_super_block * s)
431{
432 list_super2(s, stdout);
433}
Theodore Ts'o1e3472c1997-04-29 14:53:37 +0000434