static void get_root_type(ext2_filsys fs) { errcode_t retval; struct mem_file file; char *buf; struct fs_info fs_info; int ret; retval = get_file(fs, "/etc/fstab", &file); if (retval) { com_err(program_name, retval, "couldn't open /etc/fstab"); exit(1); } while (!mem_file_eof(&file)) { buf = get_line(&file); if (!buf) continue; ret = parse_fstab_line(buf, &fs_info); if (ret < 0) goto next_line; if (!strcmp(fs_info.mountpt, "/")) printf("%s\n", fs_info.type); free_fstab_line(&fs_info); next_line: free(buf); } }
/* * Load the filesystem database from /etc/fstab */ static void load_fs_info(const char *filename) { FILE *f; char buf[1024]; int lineno = 0; int old_fstab = 1; struct fs_info *fs, *fs_last = NULL; filesys_info = NULL; if ((f = fopen(filename, "r")) == NULL) { fprintf(stderr, _("WARNING: couldn't open %s: %s\n"), filename, strerror(errno)); return; } while (!feof(f)) { lineno++; if (!fgets(buf, sizeof(buf), f)) break; buf[sizeof(buf)-1] = 0; if (parse_fstab_line(buf, &fs) < 0) { fprintf(stderr, _("WARNING: bad format " "on line %d of %s\n"), lineno, filename); continue; } if (!fs) continue; if (!filesys_info) filesys_info = fs; else fs_last->next = fs; fs_last = fs; if (fs->passno < 0) fs->passno = 0; else old_fstab = 0; } fclose(f); if (old_fstab) { fprintf(stderr, _("\007\007\007" "WARNING: Your /etc/fstab does not contain the fsck passno\n" " field. I will kludge around things for you, but you\n" " should fix your /etc/fstab file as soon as you can.\n\n")); for (fs = filesys_info; fs; fs = fs->next) { fs->passno = 1; } } }