Beispiel #1
0
int main(int argc,char *argv[])
{
	FILE *fd;
	char sectbuf[256];
	int sector,read,err;

	if (argc!=4) {
		printf("Usage: writeblock disk_image blockfile sector_no\n");
		printf("\nThis tool will write <blockfile> onto side 2 of a double-sided disk image,\n");
		printf("starting at sector sector_no (zero-based).\n\n");
		printf("Caution:\n");
		printf("\t-the disk should have been previously formatted (17 sectors per track)\n");
		printf("\t-the logical sector number should not exceed the capacity of one side\n");
		exit(1);
	}
	if (open_disk(argv[1])) {
		printf("Cannot open disk image %s, or invalid disk image.\n",argv[1]);
		exit(2);
	}
	fd=fopen(argv[2],"rb");
	if (fd==NULL) {
		printf("Cannot open blockfile %s\n",argv[2]);
		exit(2);
	}
	sector=atoi(argv[3]);
	read=fread(sectbuf,1,256,fd);
	while (read>0) {
		err=write_sector(sectbuf,sector/17,1,sector%17+1);
		if (err) {
			printf("Cannot write sector, error %d\n",err);
			exit(4);
		}
		sector++;
		read=fread(sectbuf,1,256,fd);
	}
	close_disk();
}
void sfs_close_storage()
{
	close_disk();
}
Beispiel #3
0
uint8_t* shoebill_extract_kernel(const char *disk_path, const char *kernel_path, char *error_str, uint32_t *len)
{
    uint8_t *pool_data, *kernel_data = NULL;
    disk_t *disk;
    svfs_t *svfs_mount_obj;
    ufs_t *ufs_mount_obj;
    int32_t apm_part_num;
    
    strcpy(error_str, "");
    
    disk = open_disk(disk_path, error_str);
    if (!disk)
        goto done;
    
    apm_part_num = find_root_partition_number(disk, 0);
    if (apm_part_num == -1) {
        sprintf(error_str, "Couldn't find root partition");
        goto done;
    }
    slog("apm_part_num = %u\n", apm_part_num);
    
    svfs_mount_obj = svfs_mount(&disk->partitions[apm_part_num]);
    if (svfs_mount_obj) {
        svfs_inode_t *inode = svfs_traverse_path(svfs_mount_obj, kernel_path);
        if (!inode)
            goto done;
        
        pool_data = svfs_read_inode_data(svfs_mount_obj, inode);
        if (!pool_data)
            goto done;
        
        kernel_data = malloc(inode->size);
        memcpy(kernel_data, pool_data, inode->size);
        *len = inode->size;
        goto done;
    }
    
    ufs_mount_obj = ufs_mount(&disk->partitions[apm_part_num]);
    if (ufs_mount_obj) {
        ufs_inode_t *inode = ufs_traverse_path(ufs_mount_obj, kernel_path);
        if (!inode)
            goto done;
        
        pool_data = ufs_read_inode_data(ufs_mount_obj, inode);
        if (!pool_data)
            goto done;
        
        kernel_data = malloc(inode->size);
        memcpy(kernel_data, pool_data, inode->size);
        *len = inode->size;
        goto done;
    }
    
    sprintf(error_str, "I can read the partition map, but the filesystem doesn't seem to be UFS or SVFS");
    
done:
    if (strlen(error_str))
        slog("error: [%s]\n", error_str);
    if (disk)
        close_disk(disk);
    return kernel_data;
}