Annotation of qemu/block/raw.c, revision 1.1.1.3

1.1       root        1: 
                      2: #include "qemu-common.h"
                      3: #include "block_int.h"
                      4: #include "module.h"
                      5: 
                      6: static int raw_open(BlockDriverState *bs, int flags)
                      7: {
                      8:     bs->sg = bs->file->sg;
                      9:     return 0;
                     10: }
                     11: 
1.1.1.3 ! root       12: static int coroutine_fn raw_co_readv(BlockDriverState *bs, int64_t sector_num,
        !            13:                                      int nb_sectors, QEMUIOVector *qiov)
1.1       root       14: {
1.1.1.3 ! root       15:     return bdrv_co_readv(bs->file, sector_num, nb_sectors, qiov);
1.1       root       16: }
                     17: 
1.1.1.3 ! root       18: static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num,
        !            19:                                       int nb_sectors, QEMUIOVector *qiov)
1.1       root       20: {
1.1.1.3 ! root       21:     return bdrv_co_writev(bs->file, sector_num, nb_sectors, qiov);
1.1       root       22: }
                     23: 
                     24: static void raw_close(BlockDriverState *bs)
                     25: {
                     26: }
                     27: 
1.1.1.3 ! root       28: static int coroutine_fn raw_co_flush(BlockDriverState *bs)
1.1       root       29: {
1.1.1.3 ! root       30:     return bdrv_co_flush(bs->file);
1.1       root       31: }
                     32: 
                     33: static int64_t raw_getlength(BlockDriverState *bs)
                     34: {
                     35:     return bdrv_getlength(bs->file);
                     36: }
                     37: 
                     38: static int raw_truncate(BlockDriverState *bs, int64_t offset)
                     39: {
                     40:     return bdrv_truncate(bs->file, offset);
                     41: }
                     42: 
                     43: static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
                     44: {
                     45:    return 1; /* everything can be opened as raw image */
                     46: }
                     47: 
1.1.1.3 ! root       48: static int coroutine_fn raw_co_discard(BlockDriverState *bs,
        !            49:                                        int64_t sector_num, int nb_sectors)
1.1.1.2   root       50: {
1.1.1.3 ! root       51:     return bdrv_co_discard(bs->file, sector_num, nb_sectors);
1.1.1.2   root       52: }
                     53: 
1.1       root       54: static int raw_is_inserted(BlockDriverState *bs)
                     55: {
                     56:     return bdrv_is_inserted(bs->file);
                     57: }
                     58: 
1.1.1.3 ! root       59: static int raw_media_changed(BlockDriverState *bs)
        !            60: {
        !            61:     return bdrv_media_changed(bs->file);
        !            62: }
        !            63: 
        !            64: static void raw_eject(BlockDriverState *bs, int eject_flag)
1.1       root       65: {
1.1.1.3 ! root       66:     bdrv_eject(bs->file, eject_flag);
1.1       root       67: }
                     68: 
1.1.1.3 ! root       69: static void raw_lock_medium(BlockDriverState *bs, bool locked)
1.1       root       70: {
1.1.1.3 ! root       71:     bdrv_lock_medium(bs->file, locked);
1.1       root       72: }
                     73: 
                     74: static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
                     75: {
                     76:    return bdrv_ioctl(bs->file, req, buf);
                     77: }
                     78: 
                     79: static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs,
                     80:         unsigned long int req, void *buf,
                     81:         BlockDriverCompletionFunc *cb, void *opaque)
                     82: {
                     83:    return bdrv_aio_ioctl(bs->file, req, buf, cb, opaque);
                     84: }
                     85: 
                     86: static int raw_create(const char *filename, QEMUOptionParameter *options)
                     87: {
                     88:     return bdrv_create_file(filename, options);
                     89: }
                     90: 
                     91: static QEMUOptionParameter raw_create_options[] = {
                     92:     {
                     93:         .name = BLOCK_OPT_SIZE,
                     94:         .type = OPT_SIZE,
                     95:         .help = "Virtual disk size"
                     96:     },
                     97:     { NULL }
                     98: };
                     99: 
                    100: static int raw_has_zero_init(BlockDriverState *bs)
                    101: {
                    102:     return bdrv_has_zero_init(bs->file);
                    103: }
                    104: 
                    105: static BlockDriver bdrv_raw = {
                    106:     .format_name        = "raw",
                    107: 
1.1.1.3 ! root      108:     /* It's really 0, but we need to make g_malloc() happy */
1.1       root      109:     .instance_size      = 1,
                    110: 
                    111:     .bdrv_open          = raw_open,
                    112:     .bdrv_close         = raw_close,
1.1.1.3 ! root      113: 
        !           114:     .bdrv_co_readv          = raw_co_readv,
        !           115:     .bdrv_co_writev         = raw_co_writev,
        !           116:     .bdrv_co_flush_to_disk  = raw_co_flush,
        !           117:     .bdrv_co_discard        = raw_co_discard,
        !           118: 
1.1       root      119:     .bdrv_probe         = raw_probe,
                    120:     .bdrv_getlength     = raw_getlength,
                    121:     .bdrv_truncate      = raw_truncate,
                    122: 
                    123:     .bdrv_is_inserted   = raw_is_inserted,
1.1.1.3 ! root      124:     .bdrv_media_changed = raw_media_changed,
1.1       root      125:     .bdrv_eject         = raw_eject,
1.1.1.3 ! root      126:     .bdrv_lock_medium   = raw_lock_medium,
        !           127: 
1.1       root      128:     .bdrv_ioctl         = raw_ioctl,
                    129:     .bdrv_aio_ioctl     = raw_aio_ioctl,
                    130: 
                    131:     .bdrv_create        = raw_create,
                    132:     .create_options     = raw_create_options,
                    133:     .bdrv_has_zero_init = raw_has_zero_init,
                    134: };
                    135: 
                    136: static void bdrv_raw_init(void)
                    137: {
                    138:     bdrv_register(&bdrv_raw);
                    139: }
                    140: 
                    141: block_init(bdrv_raw_init);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.