cloop.c (776efef32439a31cb13a6acfe8aab833687745ad) | cloop.c (a65064816d64db463f4c24bd81dcaad62fee89eb) |
---|---|
1/* 2 * QEMU Block driver for CLOOP images 3 * 4 * Copyright (c) 2004 Johannes E. Schindelin 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 53 unchanged lines hidden (view full) --- 62static int cloop_open(BlockDriverState *bs, QDict *options, int flags, 63 Error **errp) 64{ 65 BDRVCloopState *s = bs->opaque; 66 uint32_t offsets_size, max_compressed_block_size = 1, i; 67 int ret; 68 69 bs->read_only = 1; | 1/* 2 * QEMU Block driver for CLOOP images 3 * 4 * Copyright (c) 2004 Johannes E. Schindelin 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 53 unchanged lines hidden (view full) --- 62static int cloop_open(BlockDriverState *bs, QDict *options, int flags, 63 Error **errp) 64{ 65 BDRVCloopState *s = bs->opaque; 66 uint32_t offsets_size, max_compressed_block_size = 1, i; 67 int ret; 68 69 bs->read_only = 1; |
70 bs->request_alignment = BDRV_SECTOR_SIZE; /* No sub-sector I/O supported */ | |
71 72 /* read header */ 73 ret = bdrv_pread(bs->file->bs, 128, &s->block_size, 4); 74 if (ret < 0) { 75 return ret; 76 } 77 s->block_size = be32_to_cpu(s->block_size); 78 if (s->block_size % 512) { --- 115 unchanged lines hidden (view full) --- 194 195fail: 196 g_free(s->offsets); 197 g_free(s->compressed_block); 198 g_free(s->uncompressed_block); 199 return ret; 200} 201 | 70 71 /* read header */ 72 ret = bdrv_pread(bs->file->bs, 128, &s->block_size, 4); 73 if (ret < 0) { 74 return ret; 75 } 76 s->block_size = be32_to_cpu(s->block_size); 77 if (s->block_size % 512) { --- 115 unchanged lines hidden (view full) --- 193 194fail: 195 g_free(s->offsets); 196 g_free(s->compressed_block); 197 g_free(s->uncompressed_block); 198 return ret; 199} 200 |
201static void cloop_refresh_limits(BlockDriverState *bs, Error **errp) 202{ 203 bs->request_alignment = BDRV_SECTOR_SIZE; /* No sub-sector I/O supported */ 204} 205 |
|
202static inline int cloop_read_block(BlockDriverState *bs, int block_num) 203{ 204 BDRVCloopState *s = bs->opaque; 205 206 if (s->current_block != block_num) { 207 int ret; 208 uint32_t bytes = s->offsets[block_num + 1] - s->offsets[block_num]; 209 --- 65 unchanged lines hidden (view full) --- 275 inflateEnd(&s->zstream); 276} 277 278static BlockDriver bdrv_cloop = { 279 .format_name = "cloop", 280 .instance_size = sizeof(BDRVCloopState), 281 .bdrv_probe = cloop_probe, 282 .bdrv_open = cloop_open, | 206static inline int cloop_read_block(BlockDriverState *bs, int block_num) 207{ 208 BDRVCloopState *s = bs->opaque; 209 210 if (s->current_block != block_num) { 211 int ret; 212 uint32_t bytes = s->offsets[block_num + 1] - s->offsets[block_num]; 213 --- 65 unchanged lines hidden (view full) --- 279 inflateEnd(&s->zstream); 280} 281 282static BlockDriver bdrv_cloop = { 283 .format_name = "cloop", 284 .instance_size = sizeof(BDRVCloopState), 285 .bdrv_probe = cloop_probe, 286 .bdrv_open = cloop_open, |
287 .bdrv_refresh_limits = cloop_refresh_limits, |
|
283 .bdrv_co_preadv = cloop_co_preadv, 284 .bdrv_close = cloop_close, 285}; 286 287static void bdrv_cloop_init(void) 288{ 289 bdrv_register(&bdrv_cloop); 290} 291 292block_init(bdrv_cloop_init); | 288 .bdrv_co_preadv = cloop_co_preadv, 289 .bdrv_close = cloop_close, 290}; 291 292static void bdrv_cloop_init(void) 293{ 294 bdrv_register(&bdrv_cloop); 295} 296 297block_init(bdrv_cloop_init); |