]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/type.c
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include <xfs/libxfs.h>
42 static const typ_t
*findtyp(char *name
);
43 static int type_f(int argc
, char **argv
);
47 static const cmdinfo_t type_cmd
=
48 { "type", NULL
, type_f
, 0, 1, 1, N_("[newtype]"),
49 N_("set/show current data type"), NULL
};
51 static const typ_t __typtab
[] = {
52 { TYP_AGF
, "agf", handle_struct
, agf_hfld
},
53 { TYP_AGFL
, "agfl", handle_struct
, agfl_hfld
},
54 { TYP_AGI
, "agi", handle_struct
, agi_hfld
},
55 { TYP_ATTR
, "attr", handle_struct
, attr_hfld
},
56 { TYP_BMAPBTA
, "bmapbta", handle_struct
, bmapbta_hfld
},
57 { TYP_BMAPBTD
, "bmapbtd", handle_struct
, bmapbtd_hfld
},
58 { TYP_BNOBT
, "bnobt", handle_struct
, bnobt_hfld
},
59 { TYP_CNTBT
, "cntbt", handle_struct
, cntbt_hfld
},
60 { TYP_DATA
, "data", handle_block
, NULL
},
61 { TYP_DIR2
, "dir2", handle_struct
, dir2_hfld
},
62 { TYP_DQBLK
, "dqblk", handle_struct
, dqblk_hfld
},
63 { TYP_INOBT
, "inobt", handle_struct
, inobt_hfld
},
64 { TYP_INODATA
, "inodata", NULL
, NULL
},
65 { TYP_INODE
, "inode", handle_struct
, inode_hfld
},
66 { TYP_LOG
, "log", NULL
, NULL
},
67 { TYP_RTBITMAP
, "rtbitmap", NULL
, NULL
},
68 { TYP_RTSUMMARY
, "rtsummary", NULL
, NULL
},
69 { TYP_SB
, "sb", handle_struct
, sb_hfld
},
70 { TYP_SYMLINK
, "symlink", handle_string
, NULL
},
71 { TYP_TEXT
, "text", handle_text
, NULL
},
75 static const typ_t __typtab_crc
[] = {
76 { TYP_AGF
, "agf", handle_struct
, agf_hfld
},
77 { TYP_AGFL
, "agfl", handle_struct
, agfl_crc_hfld
},
78 { TYP_AGI
, "agi", handle_struct
, agi_hfld
},
79 { TYP_ATTR
, "attr", handle_struct
, attr_hfld
},
80 { TYP_BMAPBTA
, "bmapbta", handle_struct
, bmapbta_crc_hfld
},
81 { TYP_BMAPBTD
, "bmapbtd", handle_struct
, bmapbtd_crc_hfld
},
82 { TYP_BNOBT
, "bnobt", handle_struct
, bnobt_crc_hfld
},
83 { TYP_CNTBT
, "cntbt", handle_struct
, cntbt_crc_hfld
},
84 { TYP_DATA
, "data", handle_block
, NULL
},
85 { TYP_DIR2
, "dir3", handle_struct
, dir3_hfld
},
86 { TYP_DQBLK
, "dqblk", handle_struct
, dqblk_hfld
},
87 { TYP_INOBT
, "inobt", handle_struct
, inobt_crc_hfld
},
88 { TYP_INODATA
, "inodata", NULL
, NULL
},
89 { TYP_INODE
, "inode", handle_struct
, inode_crc_hfld
},
90 { TYP_LOG
, "log", NULL
, NULL
},
91 { TYP_RTBITMAP
, "rtbitmap", NULL
, NULL
},
92 { TYP_RTSUMMARY
, "rtsummary", NULL
, NULL
},
93 { TYP_SB
, "sb", handle_struct
, sb_hfld
},
94 { TYP_SYMLINK
, "symlink", handle_string
, NULL
},
95 { TYP_TEXT
, "text", handle_text
, NULL
},
99 const typ_t
*typtab
= __typtab
;
102 type_set_tab_crc(void)
104 typtab
= __typtab_crc
;
113 for (tt
= typtab
; tt
->typnm
!= TYP_NONE
; tt
++) {
114 ASSERT(tt
->typnm
== (typnm_t
)(tt
- typtab
));
115 if (tt
->name
&& strcmp(tt
->name
, name
) == 0)
131 dbprintf(_("no current type\n"));
133 dbprintf(_("current type is \"%s\"\n"), cur_typ
->name
);
135 dbprintf(_("\n supported types are:\n "));
136 for (tt
= typtab
, count
= 0; tt
->typnm
!= TYP_NONE
; tt
++) {
137 if (tt
->name
== NULL
)
139 if ((tt
+1)->name
!= NULL
) {
140 dbprintf("%s, ", tt
->name
);
141 if ((++count
% 8) == 0)
143 } else if ((tt
+1)->typnm
== TYP_NONE
) {
144 dbprintf("%s\n", tt
->name
);
150 tt
= findtyp(argv
[1]);
152 dbprintf(_("no such type %s\n"), argv
[1]);
154 if (iocur_top
->typ
== NULL
) {
155 dbprintf(_("no current object\n"));
157 iocur_top
->typ
= cur_typ
= tt
;
167 add_command(&type_cmd
);
170 /* read/write selectors for each major data type */
175 const field_t
*fields
,
179 if (action
== DB_WRITE
)
180 write_struct(fields
, argc
, argv
);
182 print_struct(fields
, argc
, argv
);
188 const field_t
*fields
,
192 if (action
== DB_WRITE
)
193 write_string(fields
, argc
, argv
);
195 print_string(fields
, argc
, argv
);
201 const field_t
*fields
,
205 if (action
== DB_WRITE
)
206 write_block(fields
, argc
, argv
);
208 print_block(fields
, argc
, argv
);
214 const field_t
*fields
,
218 if (action
!= DB_WRITE
)
219 print_text(fields
, argc
, argv
);