2 * $Id: test_parse_mtab.c,v 1.1 2001-05-25 16:18:09 rufustfirefly Exp $
3 * test driver for the afpd_mtab_parse fn. -- rgr, 9-Apr-01.
8 #endif /* HAVE_CONFIG_H */
14 #ifdef HAVE_SYS_STAT_H
16 #endif /* HAVE_SYS_STAT_H */
18 #include "directory.h"
19 #include "parse_mtab.h"
21 /* hack. etc/afpd/directory.h would need to be patched accordingly. this
22 version ignores the filep stuff. based on the comment starting around
23 line 200 in etc/afpd/file.c (search for "fucking mess"), this may be OK.
29 /* keep-filep version. must also decrement AFPD_MTAB_DEV_AND_INODE_BITS. */
30 /* #define CNID(pst, filep) (afpd_st_cnid(pst) | CNID_FILE(filep)) */
31 #define CNID(pst, filep) (afpd_st_cnid(pst))
34 main(int argc, char **argv)
36 char *file_name = "afpd.mtab";
37 struct afpd_mount_table *table = NULL;
40 if (argc >= 3 && strcmp(argv[1], "-f") == 0) {
44 if (arg < argc && argv[arg][0] == '-') {
45 /* either they don't understand, or they must be asking for help anyway. */
46 fprintf(stderr, "Usage: %s [-f file-name] [file . . . ]\n",
50 table = afpd_mtab_parse(file_name);
55 fprintf(stderr, "File %s: Field width %d, shift %d.\n",
56 file_name, table->bits, table->shift);
57 for (id = 0; id < table->size; id++) {
58 struct afpd_mtab_entry *entry = table->table[id];
61 fprintf(stderr, " Id %d -> device %s (%d,%d) on %s -> bits 0x%08x.\n",
62 id, entry->device, entry->dev_major, entry->dev_minor,
63 entry->mount_point, entry->bit_value);
67 fprintf(stderr, "%d entries used out of a maximum of %d (1..%d).\n",
68 count, table->size-1, table->size-1);
69 for (; arg < argc; arg++) {
70 if (lstat(argv[arg], &st) != 0) {
71 fprintf(stderr, "Can't lstat '%s': code %d\n",
75 fprintf(stderr, "File %s, device (%d,%d), inode %d, CNID 0x%08x.\n",
76 argv[arg], major(st.st_dev), minor(st.st_dev), st.st_ino,
77 CNID(&st, S_ISDIR(st.st_mode) ? 1 : 0));