]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/type.c
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
64 static const typ_t
*findtyp(char *name
);
65 static int type_f(int argc
, char **argv
);
69 static const cmdinfo_t type_cmd
=
70 { "type", NULL
, type_f
, 0, 1, 1, "[newtype]",
71 "set/show current data type", NULL
};
73 const typ_t typtab
[] = {
74 { TYP_AGF
, "agf", handle_struct
, agf_hfld
},
75 { TYP_AGFL
, "agfl", handle_struct
, agfl_hfld
},
76 { TYP_AGI
, "agi", handle_struct
, agi_hfld
},
77 { TYP_ATTR
, "attr", handle_struct
, attr_hfld
},
78 { TYP_BMAPBTA
, "bmapbta", handle_struct
, bmapbta_hfld
},
79 { TYP_BMAPBTD
, "bmapbtd", handle_struct
, bmapbtd_hfld
},
80 { TYP_BNOBT
, "bnobt", handle_struct
, bnobt_hfld
},
81 { TYP_CNTBT
, "cntbt", handle_struct
, cntbt_hfld
},
82 { TYP_DATA
, "data", handle_block
, NULL
},
83 { TYP_DIR
, "dir", handle_struct
, dir_hfld
},
84 { TYP_DIR2
, "dir2", handle_struct
, dir2_hfld
},
85 { TYP_DQBLK
, "dqblk", handle_struct
, dqblk_hfld
},
86 { TYP_INOBT
, "inobt", handle_struct
, inobt_hfld
},
87 { TYP_INODATA
, "inodata", NULL
, NULL
},
88 { TYP_INODE
, "inode", handle_struct
, inode_hfld
},
89 { TYP_LOG
, "log", NULL
, NULL
},
90 { TYP_RTBITMAP
, "rtbitmap", NULL
, NULL
},
91 { TYP_RTSUMMARY
, "rtsummary", NULL
, NULL
},
92 { TYP_SB
, "sb", handle_struct
, sb_hfld
},
93 { TYP_SYMLINK
, "symlink", handle_string
, NULL
},
103 for (tt
= typtab
; tt
->name
!= NULL
; tt
++) {
104 ASSERT(tt
->typnm
== (typnm_t
)(tt
- typtab
));
105 if (strcmp(tt
->name
, name
) == 0)
121 dbprintf("no current type\n");
123 dbprintf("current type is \"%s\"\n", cur_typ
->name
);
125 dbprintf("\n supported types are:\n ");
126 for (tt
= typtab
, count
= 0; tt
->name
!= NULL
; tt
++) {
127 if ((tt
+1)->name
!= NULL
) {
128 dbprintf("%s, ", tt
->name
);
129 if ((++count
% 8) == 0)
132 dbprintf("%s\n", tt
->name
);
138 tt
= findtyp(argv
[1]);
140 dbprintf("no such type %s\n", argv
[1]);
142 if (iocur_top
->typ
== NULL
) {
143 dbprintf("no current object\n");
145 iocur_top
->typ
= cur_typ
= tt
;
155 add_command(&type_cmd
);
158 /* read/write selectors for each major data type */
163 const field_t
*fields
,
167 if (action
== DB_WRITE
)
168 write_struct(fields
, argc
, argv
);
170 print_struct(fields
, argc
, argv
);
176 const field_t
*fields
,
180 if (action
== DB_WRITE
)
181 write_string(fields
, argc
, argv
);
183 print_string(fields
, argc
, argv
);
189 const field_t
*fields
,
193 if (action
== DB_WRITE
)
194 write_block(fields
, argc
, argv
);
196 print_block(fields
, argc
, argv
);