int main(int argc, char *argv[]) { char *sfs_file; int sfs_handle; if (argc != 2) { fprintf(stderr, "Usage: %s <partition's device file>\n", argv[0]); return 1; } sfs_file = argv[1]; sfs_handle = open(sfs_file, O_RDWR); if (sfs_handle == -1) { fprintf(stderr, "Unable to browse SFS over %s\n", sfs_file); return 2; } read(sfs_handle, &sb, sizeof(sfs_super_block_t)); if (sb.type != SIMULA_FS_TYPE) { fprintf(stderr, "Invalid SFS detected. Giving up.\n"); close(sfs_handle); return 3; } browse_sfs(sfs_handle); close(sfs_handle); return 0; }
int main(int argc, char *argv[]) { char *sfs_file = SIMULA_DEFAULT_FILE; int sfs_handle; if (argc > 2) { fprintf(stderr, "Incorrect invocation. Possibilities are:\n"); fprintf(stderr, "\t%s /* Picks up %s as the default partition_file */\n", argv[0], SIMULA_DEFAULT_FILE); fprintf(stderr, "\t%s [ partition_file ]\n", argv[0]); return 1; } if (argc == 2) { sfs_file = argv[1]; } sfs_handle = open(sfs_file, O_RDWR); if (sfs_handle == -1) { fprintf(stderr, "Unable to browse SFS over %s\n", sfs_file); return 2; } read(sfs_handle, &sb, sizeof(sfs_super_block_t)); if (sb.type != SIMULA_FS_TYPE) { fprintf(stderr, "Invalid SFS detected. Giving up.\n"); close(sfs_handle); return 3; } browse_sfs(sfs_handle); close(sfs_handle); return 0; }