file-posix.c (7e0019a7196ebed177c95824875cf852e1a6f667) file-posix.c (e24d813b29d3a478a9309078487efc8ce8599f22)
1/*
2 * Block driver for RAW files (posix)
3 *
4 * Copyright (c) 2006 Fabrice Bellard
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

--- 535 unchanged lines hidden (view full) ---

544 "in this build.");
545 ret = -EINVAL;
546 goto fail;
547 }
548#endif /* !defined(CONFIG_LINUX_AIO) */
549
550 s->has_discard = true;
551 s->has_write_zeroes = true;
1/*
2 * Block driver for RAW files (posix)
3 *
4 * Copyright (c) 2006 Fabrice Bellard
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

--- 535 unchanged lines hidden (view full) ---

544 "in this build.");
545 ret = -EINVAL;
546 goto fail;
547 }
548#endif /* !defined(CONFIG_LINUX_AIO) */
549
550 s->has_discard = true;
551 s->has_write_zeroes = true;
552 bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
553 if ((bs->open_flags & BDRV_O_NOCACHE) != 0) {
554 s->needs_alignment = true;
555 }
556
557 if (fstat(s->fd, &st) < 0) {
558 ret = -errno;
559 error_setg_errno(errp, errno, "Could not stat file");
560 goto fail;

--- 33 unchanged lines hidden (view full) ---

594#endif
595
596#ifdef CONFIG_XFS
597 if (platform_test_xfs_fd(s->fd)) {
598 s->is_xfs = true;
599 }
600#endif
601
552 if ((bs->open_flags & BDRV_O_NOCACHE) != 0) {
553 s->needs_alignment = true;
554 }
555
556 if (fstat(s->fd, &st) < 0) {
557 ret = -errno;
558 error_setg_errno(errp, errno, "Could not stat file");
559 goto fail;

--- 33 unchanged lines hidden (view full) ---

593#endif
594
595#ifdef CONFIG_XFS
596 if (platform_test_xfs_fd(s->fd)) {
597 s->is_xfs = true;
598 }
599#endif
600
601 bs->supported_zero_flags = s->discard_zeroes ? BDRV_REQ_MAY_UNMAP : 0;
602 ret = 0;
603fail:
604 if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
605 unlink(filename);
606 }
607 qemu_opts_del(opts);
608 return ret;
609}

--- 1608 unchanged lines hidden (view full) ---

2218 return -ENOTSUP;
2219}
2220
2221static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
2222{
2223 BDRVRawState *s = bs->opaque;
2224
2225 bdi->unallocated_blocks_are_zero = s->discard_zeroes;
602 ret = 0;
603fail:
604 if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
605 unlink(filename);
606 }
607 qemu_opts_del(opts);
608 return ret;
609}

--- 1608 unchanged lines hidden (view full) ---

2218 return -ENOTSUP;
2219}
2220
2221static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
2222{
2223 BDRVRawState *s = bs->opaque;
2224
2225 bdi->unallocated_blocks_are_zero = s->discard_zeroes;
2226 bdi->can_write_zeroes_with_unmap = s->discard_zeroes;
2227 return 0;
2228}
2229
2230static QemuOptsList raw_create_opts = {
2231 .name = "raw-create-opts",
2232 .head = QTAILQ_HEAD_INITIALIZER(raw_create_opts.head),
2233 .desc = {
2234 {

--- 820 unchanged lines hidden ---
2226 return 0;
2227}
2228
2229static QemuOptsList raw_create_opts = {
2230 .name = "raw-create-opts",
2231 .head = QTAILQ_HEAD_INITIALIZER(raw_create_opts.head),
2232 .desc = {
2233 {

--- 820 unchanged lines hidden ---