H A D | ubd_kern.c | 266 struct ubd *ubd_dev; ubd_setup_common() local 319 ubd_dev = &ubd_devs[n]; ubd_setup_common() 320 if(ubd_dev->file != NULL){ ubd_setup_common() 338 ubd_dev->no_cow = 1; ubd_setup_common() 341 ubd_dev->shared = 1; ubd_setup_common() 367 if(ubd_dev->no_cow){ ubd_setup_common() 377 ubd_dev->file = str; ubd_setup_common() 378 ubd_dev->cow.file = backing_file; ubd_setup_common() 379 ubd_dev->boot_openflags = flags; ubd_setup_common() 497 static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out) ubd_file_size() argument 511 if (ubd_dev->file && ubd_dev->cow.file) { ubd_file_size() 512 file = ubd_dev->cow.file; ubd_file_size() 517 fd = os_open_file(ubd_dev->file, of_read(OPENFLAGS()), 0); ubd_file_size() 526 file = ubd_dev->file; ubd_file_size() 720 static void ubd_close_dev(struct ubd *ubd_dev) ubd_close_dev() argument 722 os_close_file(ubd_dev->fd); ubd_close_dev() 723 if(ubd_dev->cow.file == NULL) ubd_close_dev() 726 os_close_file(ubd_dev->cow.fd); ubd_close_dev() 727 vfree(ubd_dev->cow.bitmap); ubd_close_dev() 728 ubd_dev->cow.bitmap = NULL; ubd_close_dev() 731 static int ubd_open_dev(struct ubd *ubd_dev) ubd_open_dev() argument 738 ubd_dev->openflags = ubd_dev->boot_openflags; ubd_open_dev() 740 create_ptr = (ubd_dev->cow.file != NULL) ? &create_cow : NULL; ubd_open_dev() 741 back_ptr = ubd_dev->no_cow ? NULL : &ubd_dev->cow.file; ubd_open_dev() 743 fd = open_ubd_file(ubd_dev->file, &ubd_dev->openflags, ubd_dev->shared, ubd_open_dev() 744 back_ptr, &ubd_dev->cow.bitmap_offset, ubd_open_dev() 745 &ubd_dev->cow.bitmap_len, &ubd_dev->cow.data_offset, ubd_open_dev() 749 fd = create_cow_file(ubd_dev->file, ubd_dev->cow.file, ubd_open_dev() 750 ubd_dev->openflags, 1 << 9, PAGE_SIZE, ubd_open_dev() 751 &ubd_dev->cow.bitmap_offset, ubd_open_dev() 752 &ubd_dev->cow.bitmap_len, ubd_open_dev() 753 &ubd_dev->cow.data_offset); ubd_open_dev() 756 "\"%s\"\n", ubd_dev->file, ubd_dev->cow.file); ubd_open_dev() 761 printk("Failed to open '%s', errno = %d\n", ubd_dev->file, ubd_open_dev() 765 ubd_dev->fd = fd; ubd_open_dev() 767 if(ubd_dev->cow.file != NULL){ ubd_open_dev() 768 blk_queue_max_hw_sectors(ubd_dev->queue, 8 * sizeof(long)); ubd_open_dev() 771 ubd_dev->cow.bitmap = vmalloc(ubd_dev->cow.bitmap_len); ubd_open_dev() 772 if(ubd_dev->cow.bitmap == NULL){ ubd_open_dev() 778 err = read_cow_bitmap(ubd_dev->fd, ubd_dev->cow.bitmap, ubd_open_dev() 779 ubd_dev->cow.bitmap_offset, ubd_open_dev() 780 ubd_dev->cow.bitmap_len); ubd_open_dev() 784 flags = ubd_dev->openflags; ubd_open_dev() 786 err = open_ubd_file(ubd_dev->cow.file, &flags, ubd_dev->shared, NULL, ubd_open_dev() 789 ubd_dev->cow.fd = err; ubd_open_dev() 793 os_close_file(ubd_dev->fd); ubd_open_dev() 799 struct ubd *ubd_dev = dev_get_drvdata(dev); ubd_device_release() local 801 blk_cleanup_queue(ubd_dev->queue); ubd_device_release() 802 *ubd_dev = ((struct ubd) DEFAULT_UBD); ubd_device_release() 845 struct ubd *ubd_dev = &ubd_devs[n]; ubd_add() local 848 if(ubd_dev->file == NULL) ubd_add() 851 err = ubd_file_size(ubd_dev, &ubd_dev->size); ubd_add() 857 ubd_dev->size = ROUND_BLOCK(ubd_dev->size); ubd_add() 859 INIT_LIST_HEAD(&ubd_dev->restart); ubd_add() 860 sg_init_table(ubd_dev->sg, MAX_SG); ubd_add() 863 ubd_dev->queue = blk_init_queue(do_ubd_request, &ubd_dev->lock); ubd_add() 864 if (ubd_dev->queue == NULL) { ubd_add() 868 ubd_dev->queue->queuedata = ubd_dev; ubd_add() 869 blk_queue_flush(ubd_dev->queue, REQ_FLUSH); ubd_add() 871 blk_queue_max_segments(ubd_dev->queue, MAX_SG); ubd_add() 872 err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, &ubd_gendisk[n]); ubd_add() 879 ubd_disk_register(fake_major, ubd_dev->size, n, ubd_add() 894 blk_cleanup_queue(ubd_dev->queue); ubd_add() 937 struct ubd *ubd_dev; ubd_get_config() local 946 ubd_dev = &ubd_devs[n]; ubd_get_config() 949 if(ubd_dev->file == NULL){ ubd_get_config() 954 CONFIG_CHUNK(str, size, len, ubd_dev->file, 0); ubd_get_config() 956 if(ubd_dev->cow.file != NULL){ ubd_get_config() 958 CONFIG_CHUNK(str, size, len, ubd_dev->cow.file, 1); ubd_get_config() 980 struct ubd *ubd_dev; ubd_remove() local 985 ubd_dev = &ubd_devs[n]; ubd_remove() 987 if(ubd_dev->file == NULL) ubd_remove() 992 if(ubd_dev->count > 0) ubd_remove() 1008 platform_device_unregister(&ubd_dev->pdev); ubd_remove() 1036 struct ubd *ubd_dev = &ubd_devs[0]; ubd0_init() local 1039 if(ubd_dev->file == NULL) ubd0_init() 1040 ubd_dev->file = "root_fs"; ubd0_init() 1116 struct ubd *ubd_dev = disk->private_data; ubd_open() local 1120 if(ubd_dev->count == 0){ ubd_open() 1121 err = ubd_open_dev(ubd_dev); ubd_open() 1124 disk->disk_name, ubd_dev->file, -err); ubd_open() 1128 ubd_dev->count++; ubd_open() 1129 set_disk_ro(disk, !ubd_dev->openflags.w); ubd_open() 1133 /*if((mode & FMODE_WRITE) && !ubd_dev->openflags.w){ ubd_open() 1134 if(--ubd_dev->count == 0) ubd_close_dev(ubd_dev); ubd_open() 1144 struct ubd *ubd_dev = disk->private_data; ubd_release() local 1147 if(--ubd_dev->count == 0) ubd_release() 1148 ubd_close_dev(ubd_dev); ubd_release() 1218 struct ubd *ubd_dev = disk->private_data; prepare_request() local 1221 io_req->fds[0] = (ubd_dev->cow.file != NULL) ? ubd_dev->cow.fd : prepare_request() 1222 ubd_dev->fd; prepare_request() 1223 io_req->fds[1] = ubd_dev->fd; prepare_request() 1232 io_req->offsets[1] = ubd_dev->cow.data_offset; prepare_request() 1236 if(ubd_dev->cow.file != NULL) prepare_request() 1237 cowify_req(io_req, ubd_dev->cow.bitmap, prepare_request() 1238 ubd_dev->cow.bitmap_offset, ubd_dev->cow.bitmap_len); prepare_request() 1247 struct ubd *ubd_dev = disk->private_data; prepare_flush_request() local 1250 io_req->fds[0] = (ubd_dev->cow.file != NULL) ? ubd_dev->cow.fd : prepare_flush_request() 1251 ubd_dev->fd; prepare_flush_request() 1333 struct ubd *ubd_dev = bdev->bd_disk->private_data; ubd_getgeo() local 1337 geo->cylinders = ubd_dev->size / (128 * 32 * 512); ubd_getgeo() 1344 struct ubd *ubd_dev = bdev->bd_disk->private_data; ubd_ioctl() local 1351 ubd_id[ATA_ID_CYLS] = ubd_dev->size / (128 * 32 * 512); ubd_ioctl()
|