Exemple #1
0
s32 WBFS_OpenPart(u32 part_fs, u32 part_idx, u32 part_lba, u32 part_size, char *partition)
{
	// close
	WBFS_Close();

	dbg_printf("openpart(%d %d %d %d)\n", part_fs, part_idx, part_lba, part_size);
	if (part_fs == PART_FS_UNK) return -1;
	if (part_fs == PART_FS_WBFS) {
		if (WBFS_OpenLBA(part_lba, part_size)) return -1;
	} else {
		MountPoint *mp = mount_find_part(wbfsDev, part_lba);
		if (mp) {
			mount_name2drive(mp->name, wbfs_fs_drive);
		} else {
			if (MountFS(GAME_MOUNT, wbfsDev, part_lba, part_fs, 1)) return -1;
			mount_name2drive(GAME_MOUNT, wbfs_fs_drive);
		}
	}

	// success
	wbfs_part_fs  = part_fs;
	wbfs_part_idx = part_idx;
	wbfs_part_lba = part_lba;
	sprintf(partition, "%s%d", get_fs_name(part_fs), wbfs_part_idx);
	dbg_printf("game part=%s\n", partition);
	return 0;
}
Exemple #2
0
int main(int argc, char *argv[]) {

    ext2_ino_t inode;
    struct ext2_inode *inode_buf;
    struct ext2_inode_large *large_inode;
    int retval;
    char *fs;

    if (argc != 2) {
        fprintf(stderr, "Usage: crtime <file>\n");
        return -1;
    }

    retval = check_permissions(argv[1]);
    if (retval) {
        return retval;
    }

    retval = get_inode(argv[1], &inode);
    if (retval) {
        return retval;
    }

    retval = get_fs_name(argv[1], &fs);
    if (retval) {
        return retval;
    }

    retval = open_filesystem(fs);
    if (retval) {
        free(fs);
        return retval;
    }

    inode_buf = (struct ext2_inode *)malloc(EXT2_INODE_SIZE(current_fs->super));
    if (!inode_buf) {
        free(fs);
        fprintf(stderr, "Failed to allocate memory\n");
        return -1;
    }

    retval = ext2fs_read_inode_full(current_fs, inode, inode_buf, EXT2_INODE_SIZE(current_fs->super));
    if (retval) {
        fprintf(stderr, "Failed to read inode\n");
        free(fs);
        free(inode_buf);
        return retval;
    }

    if (EXT2_INODE_SIZE(current_fs->super) <= EXT2_GOOD_OLD_INODE_SIZE) {
        free(fs);
        free(inode_buf);
        fprintf(stderr, "Create time unavailable");
        return -1;
    }

    large_inode = (struct ext2_inode_large *)inode_buf;
    if (large_inode->i_extra_isize < 24) {
        free(fs);
        free(inode_buf);
        fprintf(stderr, "Create time unavailable");
        return -1;
    }

    printf("%d\n", large_inode->i_crtime);

    free(fs);
    free(inode_buf);
    ext2fs_close(current_fs);
    return 0;
}
Exemple #3
0
s32 WBFS_OpenNamed(char *partition)
{
	int i = 0;
	u32 part_fs  = PART_FS_WBFS;
	u32 part_idx = 0;
	u32 part_lba = 0;
	s32 ret = 0;
	PartList plist;
	int x, fs;

	// close
	WBFS_Close();

	dbg_printf("open_part(%s)\n", partition);

	// Get partition entries
	ret = Partition_GetList(wbfsDev, &plist);
	if (ret || plist.num == 0) return -1;

	// parse partition option
	if (strcasecmp(partition, "auto") == 0) {
		int fs_list[] = { PART_FS_WBFS, PART_FS_FAT, PART_FS_NTFS }; // PART_FS_EXT
		int n = sizeof(fs_list) / sizeof(int);
		for (x=0; x<n; x++) {
			fs = fs_list[x];
			i = PartList_FindFS(&plist, fs, 1, NULL);
			if (i < 0) continue;
			if ((fs == PART_FS_WBFS) || is_game_fs(wbfsDev, plist.pentry[i].sector)) {
				part_fs = fs;
				part_idx = 1;
				goto found;
			}
		}
	} else {
		for (x=0; x<PART_FS_NUM; x++) {
			fs = PART_FS_FIRST + x;
			char *fsname = get_fs_name(fs);
			int len = strlen(fsname);
			if (strncasecmp(partition, fsname, len) == 0) {
				int idx = atoi(partition + len);
				if (idx < 1 || idx > 9) goto err;
				i = PartList_FindFS(&plist, fs, idx, NULL);
				if (i >= 0) {
					part_fs = fs;
					part_idx = idx;
					goto found;
				}
			}
		}
	}
	// nothing found
	goto err;

found:
	if (i >= plist.num) goto err;
	// set partition lba sector
	part_lba = plist.pentry[i].sector;

	if (WBFS_OpenPart(part_fs, part_idx, part_lba, plist.pentry[i].size, partition)) {
		goto err;
	}
	// success
	dbg_printf("OK! partition=%s\n", partition);
	return 0;

err:
	Gui_Console_Enable();
	printf(gt("Invalid partition: '%s'"), partition);
	printf("\n");
	__console_flush(0);
	sleep(2);
	return -1;
}