2
Replace DIOCGDELETE call in berase() with a portable implementation instead
5
Patch from upstream (r228349).
7
--- a/lib/libufs/block.c
8
+++ b/lib/libufs/block.c
13
+#ifdef __FreeBSD_kernel__
16
+berase_helper(struct uufsd *disk, ufs2_daddr_t blockno, ufs2_daddr_t size)
20
+ ioarg[0] = blockno * disk->d_bsize;
22
+ return (ioctl(disk->d_fd, DIOCGDELETE, ioarg));
28
+berase_helper(struct uufsd *disk, ufs2_daddr_t blockno, ufs2_daddr_t size)
31
+ off_t offset, zero_chunk_size, pwrite_size;
34
+ offset = blockno * disk->d_bsize;
35
+ zero_chunk_size = 65536 * disk->d_bsize;
36
+ zero_chunk = calloc(1, zero_chunk_size);
37
+ if (zero_chunk == NULL) {
38
+ ERROR(disk, "failed to allocate memory");
43
+ if (pwrite_size > zero_chunk_size)
44
+ pwrite_size = zero_chunk_size;
45
+ rv = pwrite(disk->d_fd, zero_chunk, pwrite_size, offset);
47
+ ERROR(disk, "failed writing to disk");
61
berase(struct uufsd *disk, ufs2_daddr_t blockno, ufs2_daddr_t size)
68
ERROR(disk, "failed to open disk for writing");
71
- ioarg[0] = blockno * disk->d_bsize;
73
- rv = ioctl(disk->d_fd, DIOCGDELETE, ioarg);
75
+ return (berase_helper(disk, blockno, size));