ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
- _cleanup_close_ int pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
- ASSERT_OK_ERRNO(pfd);
+ _cleanup_close_ int pfd = -EBADF;
+ ASSERT_OK_ERRNO(pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
uint64_t size;
ASSERT_OK(blockdev_get_device_size(pfd, &size));
ASSERT_EQ(size, 20U*1024U*1024U);
+ pfd = safe_close(pfd);
/* No change */
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
+ ASSERT_OK_ERRNO(pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
ASSERT_OK(blockdev_get_device_size(pfd, &size));
ASSERT_EQ(size, 30U*1024U*1024U);
+ pfd = safe_close(pfd);
/* No change */
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
+ ASSERT_OK_ERRNO(pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
/* Move */
log_notice("MOVING BY 50M");
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
ASSERT_ERROR(reread_partition_table_fd(loop->fd, /* flags= */ 0), EBUSY);
- ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
-
- safe_close(pfd);
+ pfd = safe_close(pfd);
+ ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
- pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
- ASSERT_OK_ERRNO(pfd);
+ pfd = ASSERT_OK_ERRNO(open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
ASSERT_OK(blockdev_get_device_size(pfd, &size));
ASSERT_EQ(size, 15U*1024U*1024U);
+ pfd = safe_close(pfd);
/* No change */
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
+ pfd = ASSERT_OK_ERRNO(open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
/* Remove */
log_notice("REMOVING");
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
ASSERT_ERROR(reread_partition_table_fd(loop->fd, /* flags= */ 0), EBUSY);
+ pfd = safe_close(pfd);
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
- pfd = safe_close(pfd);
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
ASSERT_ERROR_ERRNO(access(p, F_OK), ENOENT);
}