ls.c revision 494a1daad37a8098e7db166d558aab3e9e37ac48
13839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 23839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * ls.c - List the contents of an ext2fs superblock 33839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * 43839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Copyright (C) 1992, 1993, 1994 Remy Card <card@masi.ibp.fr> 53839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Laboratoire MASI, Institut Blaise Pascal 63839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Universite Pierre et Marie Curie (Paris VI) 73839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * 821c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o * Copyright (C) 1995, 1996, 1997 Theodore Ts'o <tytso@mit.edu> 921c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o * 103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * This file can be redistributed under the terms of the GNU Library General 113839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Public License 123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 141e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#include <stdio.h> 15b7e4eef304d20fabbe2dd6bfeb1bc217db280e48Theodore Ts'o#include <stdlib.h> 1650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#include <sys/types.h> 171e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#include <string.h> 18f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o#include <grp.h> 19f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o#include <pwd.h> 203839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include <time.h> 213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 223839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include "e2p.h" 233839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 2453d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'ostatic void print_user (unsigned short uid, FILE *f) 25f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o{ 26f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o struct passwd *pw; 27f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 2853d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "%u ", uid); 29f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o pw = getpwuid (uid); 30f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o if (pw == NULL) 3153d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "(user unknown)\n"); 32f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o else 3353d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "(user %s)\n", pw->pw_name); 34f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o} 35f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 3653d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'ostatic void print_group (unsigned short gid, FILE *f) 37f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o{ 38f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o struct group *gr; 39f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 4053d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "%u ", gid); 41f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o gr = getgrgid (gid); 42f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o if (gr == NULL) 4353d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "(group unknown)\n"); 44f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o else 4553d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "(group %s)\n", gr->gr_name); 46f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o} 47f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 481e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define MONTH_INT (86400 * 30) 491e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define WEEK_INT (86400 * 7) 501e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define DAY_INT (86400) 511e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define HOUR_INT (60 * 60) 521e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define MINUTE_INT (60) 531e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 5421c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'ostatic const char *interval_string(unsigned int secs) 551e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o{ 561e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o static char buf[256], tmp[80]; 571e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o int hr, min, num; 581e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 591e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o buf[0] = 0; 601e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 6121c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o if (secs == 0) 6221c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o return "<none>"; 6321c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o 641e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o if (secs >= MONTH_INT) { 651e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o num = secs / MONTH_INT; 661e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o secs -= num*MONTH_INT; 671e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o sprintf(buf, "%d month%s", num, (num>1) ? "s" : ""); 681e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o } 691e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o if (secs >= WEEK_INT) { 701e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o num = secs / WEEK_INT; 711e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o secs -= num*WEEK_INT; 721e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o sprintf(tmp, "%s%d week%s", buf[0] ? ", " : "", 731e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o num, (num>1) ? "s" : ""); 741e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o strcat(buf, tmp); 751e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o } 761e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o if (secs >= DAY_INT) { 771e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o num = secs / DAY_INT; 781e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o secs -= num*DAY_INT; 791e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o sprintf(tmp, "%s%d day%s", buf[0] ? ", " : "", 801e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o num, (num>1) ? "s" : ""); 811e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o strcat(buf, tmp); 821e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o } 831e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o if (secs > 0) { 841e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o hr = secs / HOUR_INT; 851e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o secs -= hr*HOUR_INT; 861e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o min = secs / MINUTE_INT; 871e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o secs -= min*MINUTE_INT; 881e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o sprintf(tmp, "%s%d:%02d:%02d", buf[0] ? ", " : "", 891e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o hr, min, secs); 901e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o strcat(buf, tmp); 911e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o } 921e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o return buf; 931e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o} 941e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 9553d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'ostatic void print_features(struct ext2_super_block * s, FILE *f) 96d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o{ 97d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o#ifdef EXT2_DYNAMIC_REV 98d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o int i, j, printed=0; 99d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o __u32 *mask = &s->s_feature_compat, m; 100d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o 10153d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Filesystem features: "); 102d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o for (i=0; i <3; i++,mask++) { 103d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o for (j=0,m=1; j < 32; j++, m<<=1) { 104d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o if (*mask & m) { 10553d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, " %s", e2p_feature2string(i, m)); 106d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o printed++; 107d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o } 108d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o } 109d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o } 110d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o if (printed == 0) 1116d21621c0ce194fd3c8474b8066a06c4781fb4bcTheodore Ts'o fprintf(f, " (none)"); 11253d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "\n"); 113d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o#endif 114d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o} 115d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o 116a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'ostatic void print_mntopts(struct ext2_super_block * s, FILE *f) 117a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o{ 118a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o#ifdef EXT2_DYNAMIC_REV 119a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o int i, printed=0; 120a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o __u32 mask = s->s_default_mount_opts, m; 121a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o 122a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o fprintf(f, "Default mount options: "); 1234a959fe6f18a3b6023234a66f4455f7ec660b8b4Theodore Ts'o if (mask & EXT3_DEFM_JMODE) { 1244a959fe6f18a3b6023234a66f4455f7ec660b8b4Theodore Ts'o fprintf(f, " %s", e2p_mntopt2string(mask & EXT3_DEFM_JMODE)); 1254a959fe6f18a3b6023234a66f4455f7ec660b8b4Theodore Ts'o printed++; 1264a959fe6f18a3b6023234a66f4455f7ec660b8b4Theodore Ts'o } 127a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o for (i=0,m=1; i < 32; i++, m<<=1) { 1284a959fe6f18a3b6023234a66f4455f7ec660b8b4Theodore Ts'o if (m & EXT3_DEFM_JMODE) 1294a959fe6f18a3b6023234a66f4455f7ec660b8b4Theodore Ts'o continue; 130a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o if (mask & m) { 1314a959fe6f18a3b6023234a66f4455f7ec660b8b4Theodore Ts'o fprintf(f, " %s", e2p_mntopt2string(m)); 132a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o printed++; 133a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o } 134a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o } 135a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o if (printed == 0) 136a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o fprintf(f, " (none)"); 137a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o fprintf(f, "\n"); 138a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o#endif 139a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o} 140d7b701ded6fda284d7c77cd5ac48c2607ff72b13Theodore Ts'o 141f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'ostatic void print_super_flags(struct ext2_super_block * s, FILE *f) 142f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o{ 143f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o int flags_found = 0; 144f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o 145f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o if (s->s_flags == 0) 146f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o return; 147f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o 148f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o fputs("Filesystem flags: ", f); 149f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o if (s->s_flags & EXT2_FLAGS_SIGNED_HASH) { 1506cb27404f51f97e2665fa0e0c4c0f7bc47e698ecTheodore Ts'o fputs("signed_directory_hash ", f); 151f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o flags_found++; 152f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o } 153f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o if (s->s_flags & EXT2_FLAGS_UNSIGNED_HASH) { 1546cb27404f51f97e2665fa0e0c4c0f7bc47e698ecTheodore Ts'o fputs("unsigned_directory_hash ", f); 1556cb27404f51f97e2665fa0e0c4c0f7bc47e698ecTheodore Ts'o flags_found++; 1566cb27404f51f97e2665fa0e0c4c0f7bc47e698ecTheodore Ts'o } 1576cb27404f51f97e2665fa0e0c4c0f7bc47e698ecTheodore Ts'o if (s->s_flags & EXT2_FLAGS_TEST_FILESYS) { 1586cb27404f51f97e2665fa0e0c4c0f7bc47e698ecTheodore Ts'o fputs("test_filesystem ", f); 159f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o flags_found++; 160f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o } 161f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o if (flags_found) 162f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o fputs("\n", f); 163f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o else 164f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o fputs("(none)\n", f); 165f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o} 166f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o 1671e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 1687f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o#ifndef EXT2_INODE_SIZE 1697f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o#define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode) 1707f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o#endif 1717f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o 172a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o#ifndef EXT2_GOOD_OLD_REV 173a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o#define EXT2_GOOD_OLD_REV 0 174a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o#endif 175a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o 176379955feee57506fc1f1824c5223399690ea0465Theodore Ts'ovoid list_super2(struct ext2_super_block * sb, FILE *f) 1773839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 1787f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o int inode_blocks_per_group; 17963253946309651c1015947d522e2ba4b35a807a5Theodore Ts'o char buf[80], *str; 18021c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o time_t tm; 1817f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o 182379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o inode_blocks_per_group = (((sb->s_inodes_per_group * 183379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o EXT2_INODE_SIZE(sb)) + 184379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o EXT2_BLOCK_SIZE(sb) - 1) / 185379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o EXT2_BLOCK_SIZE(sb)); 1861e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o if (sb->s_volume_name[0]) { 1871e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o memset(buf, 0, sizeof(buf)); 1881e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o strncpy(buf, sb->s_volume_name, sizeof(sb->s_volume_name)); 18921c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o } else 19021c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o strcpy(buf, "<none>"); 19153d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Filesystem volume name: %s\n", buf); 1921e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o if (sb->s_last_mounted[0]) { 1931e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o memset(buf, 0, sizeof(buf)); 1941e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o strncpy(buf, sb->s_last_mounted, sizeof(sb->s_last_mounted)); 19521c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o } else 19621c84b71e205b5ab13f14343da5645dcc985856dTheodore Ts'o strcpy(buf, "<not available>"); 19753d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Last mounted on: %s\n", buf); 198f61fc0b5d98ef2455252d596e7b20131526d6762Theodore Ts'o fprintf(f, "Filesystem UUID: %s\n", e2p_uuid2str(sb->s_uuid)); 199379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Filesystem magic number: 0x%04X\n", sb->s_magic); 200379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Filesystem revision #: %d", sb->s_rev_level); 201379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o if (sb->s_rev_level == EXT2_GOOD_OLD_REV) { 20253d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, " (original)\n"); 203521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o#ifdef EXT2_DYNAMIC_REV 204379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o } else if (sb->s_rev_level == EXT2_DYNAMIC_REV) { 20553d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, " (dynamic)\n"); 206521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o#endif 207521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o } else 2086d21621c0ce194fd3c8474b8066a06c4781fb4bcTheodore Ts'o fprintf(f, " (unknown)\n"); 209379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o print_features(sb, f); 210f77704e416fca7dbe4cc91abba674d2ae3c14f6fTheodore Ts'o print_super_flags(sb, f); 211a0c3fd5e4cdc2e0b032c9ace89d960a622069c32Theodore Ts'o print_mntopts(sb, f); 21253d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Filesystem state: "); 213379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o print_fs_state (f, sb->s_state); 21453d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "\n"); 21553d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Errors behavior: "); 216379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o print_fs_errors(f, sb->s_errors); 21753d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "\n"); 21863253946309651c1015947d522e2ba4b35a807a5Theodore Ts'o str = e2p_os2string(sb->s_creator_os); 21963253946309651c1015947d522e2ba4b35a807a5Theodore Ts'o fprintf(f, "Filesystem OS type: %s\n", str); 22063253946309651c1015947d522e2ba4b35a807a5Theodore Ts'o free(str); 221379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Inode count: %u\n", sb->s_inodes_count); 222379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Block count: %u\n", sb->s_blocks_count); 223379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Reserved block count: %u\n", sb->s_r_blocks_count); 224379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Free blocks: %u\n", sb->s_free_blocks_count); 225379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Free inodes: %u\n", sb->s_free_inodes_count); 226379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "First block: %u\n", sb->s_first_data_block); 227379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb)); 228379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb)); 229faeaf937523f452d9ad579445b88b8949a76d57aTheodore Ts'o if (sb->s_reserved_gdt_blocks) 230faeaf937523f452d9ad579445b88b8949a76d57aTheodore Ts'o fprintf(f, "Reserved GDT blocks: %u\n", 231faeaf937523f452d9ad579445b88b8949a76d57aTheodore Ts'o sb->s_reserved_gdt_blocks); 232379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group); 233379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group); 234379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Inodes per group: %u\n", sb->s_inodes_per_group); 23553d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Inode blocks per group: %u\n", inode_blocks_per_group); 2366b226c3de2aea0ae3a44a56d0322ba3a7f561886Theodore Ts'o if (sb->s_raid_stride) 237395529bb4676856a026f5f0c92d494491c3ebb75Theodore Ts'o fprintf(f, "RAID stride: %u\n", 2386b226c3de2aea0ae3a44a56d0322ba3a7f561886Theodore Ts'o sb->s_raid_stride); 2396b226c3de2aea0ae3a44a56d0322ba3a7f561886Theodore Ts'o if (sb->s_raid_stripe_width) 240395529bb4676856a026f5f0c92d494491c3ebb75Theodore Ts'o fprintf(f, "RAID stripe width: %u\n", 2416b226c3de2aea0ae3a44a56d0322ba3a7f561886Theodore Ts'o sb->s_raid_stripe_width); 242c046ac7f2e4c53e20cf1e909bbe511f91074b396Theodore Ts'o if (sb->s_first_meta_bg) 243c046ac7f2e4c53e20cf1e909bbe511f91074b396Theodore Ts'o fprintf(f, "First meta block group: %u\n", 244c046ac7f2e4c53e20cf1e909bbe511f91074b396Theodore Ts'o sb->s_first_meta_bg); 245494a1daad37a8098e7db166d558aab3e9e37ac48Theodore Ts'o if (sb->s_log_groups_per_flex) 246494a1daad37a8098e7db166d558aab3e9e37ac48Theodore Ts'o fprintf(f, "Flex block group size: %u\n", 247494a1daad37a8098e7db166d558aab3e9e37ac48Theodore Ts'o 1 << sb->s_log_groups_per_flex); 2489d2aefb3bc0a48b1540d06e1983aa96c56d39e17Theodore Ts'o if (sb->s_mkfs_time) { 2499d2aefb3bc0a48b1540d06e1983aa96c56d39e17Theodore Ts'o tm = sb->s_mkfs_time; 2509d2aefb3bc0a48b1540d06e1983aa96c56d39e17Theodore Ts'o fprintf(f, "Filesystem created: %s", ctime(&tm)); 2519d2aefb3bc0a48b1540d06e1983aa96c56d39e17Theodore Ts'o } 2529d2aefb3bc0a48b1540d06e1983aa96c56d39e17Theodore Ts'o tm = sb->s_mtime; 2539d2aefb3bc0a48b1540d06e1983aa96c56d39e17Theodore Ts'o fprintf(f, "Last mount time: %s", 2549d2aefb3bc0a48b1540d06e1983aa96c56d39e17Theodore Ts'o sb->s_mtime ? ctime(&tm) : "n/a\n"); 255379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o tm = sb->s_wtime; 25653d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Last write time: %s", ctime(&tm)); 257379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Mount count: %u\n", sb->s_mnt_count); 258379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Maximum mount count: %d\n", sb->s_max_mnt_count); 259379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o tm = sb->s_lastcheck; 26053d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Last checked: %s", ctime(&tm)); 261379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "Check interval: %u (%s)\n", sb->s_checkinterval, 262379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o interval_string(sb->s_checkinterval)); 263379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o if (sb->s_checkinterval) 2643839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o { 2653839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o time_t next; 2663839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 267379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o next = sb->s_lastcheck + sb->s_checkinterval; 26853d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Next check after: %s", ctime(&next)); 2693839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o } 27053d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Reserved blocks uid: "); 271379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o print_user(sb->s_def_resuid, f); 27253d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o fprintf(f, "Reserved blocks gid: "); 273379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o print_group(sb->s_def_resgid, f); 274379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o if (sb->s_rev_level >= EXT2_DYNAMIC_REV) { 275379955feee57506fc1f1824c5223399690ea0465Theodore Ts'o fprintf(f, "First inode: %d\n", sb->s_first_ino); 27641a5afa87b0408bc213d72712a0f6fa9177680c4Theodore Ts'o fprintf(f, "Inode size: %d\n", sb->s_inode_size); 27741a5afa87b0408bc213d72712a0f6fa9177680c4Theodore Ts'o if (sb->s_min_extra_isize) 27841a5afa87b0408bc213d72712a0f6fa9177680c4Theodore Ts'o fprintf(f, "Required extra isize: %d\n", 27941a5afa87b0408bc213d72712a0f6fa9177680c4Theodore Ts'o sb->s_min_extra_isize); 28041a5afa87b0408bc213d72712a0f6fa9177680c4Theodore Ts'o if (sb->s_want_extra_isize) 28141a5afa87b0408bc213d72712a0f6fa9177680c4Theodore Ts'o fprintf(f, "Desired extra isize: %d\n", 28241a5afa87b0408bc213d72712a0f6fa9177680c4Theodore Ts'o sb->s_want_extra_isize); 2837f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o } 2849522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o if (!e2p_is_null_uuid(sb->s_journal_uuid)) 285f61fc0b5d98ef2455252d596e7b20131526d6762Theodore Ts'o fprintf(f, "Journal UUID: %s\n", 286f61fc0b5d98ef2455252d596e7b20131526d6762Theodore Ts'o e2p_uuid2str(sb->s_journal_uuid)); 2879522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o if (sb->s_journal_inum) 2889522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o fprintf(f, "Journal inode: %u\n", 2899522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o sb->s_journal_inum); 2909522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o if (sb->s_journal_dev) 2919522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o fprintf(f, "Journal device: 0x%04x\n", 2929522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o sb->s_journal_dev); 2939522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o if (sb->s_last_orphan) 2949522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o fprintf(f, "First orphan inode: %u\n", 2959522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o sb->s_last_orphan); 2969522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o if ((sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) || 2979522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o sb->s_def_hash_version) 298f61fc0b5d98ef2455252d596e7b20131526d6762Theodore Ts'o fprintf(f, "Default directory hash: %s\n", 299f61fc0b5d98ef2455252d596e7b20131526d6762Theodore Ts'o e2p_hash2string(sb->s_def_hash_version)); 3009522e0aa0408a541423992f747ce49219fea97ffTheodore Ts'o if (!e2p_is_null_uuid(sb->s_hash_seed)) 301f61fc0b5d98ef2455252d596e7b20131526d6762Theodore Ts'o fprintf(f, "Directory Hash Seed: %s\n", 302f61fc0b5d98ef2455252d596e7b20131526d6762Theodore Ts'o e2p_uuid2str(sb->s_hash_seed)); 303a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o if (sb->s_jnl_backup_type) { 304a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o fprintf(f, "Journal backup: "); 305a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o switch (sb->s_jnl_backup_type) { 306a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o case 1: 307a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o fprintf(f, "inode blocks\n"); 308a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o break; 309a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o default: 310a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o fprintf(f, "type %u\n", sb->s_jnl_backup_type); 311a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o } 312a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o } 3133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 3141e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 31553d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'ovoid list_super (struct ext2_super_block * s) 31653d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o{ 31753d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o list_super2(s, stdout); 31853d3955001593b668b15e2d10b3a191f689f9779Theodore Ts'o} 3191e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 320