/*
- * Copyright (c) 2000-2010 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* D_CANFREE We support B_FREEBUF
*/
-static struct bdevsw vn_bdevsw = {
- /* open */ vnopen,
- /* close */ vnclose,
- /* strategy */ vnstrategy,
- /* ioctl */ vnioctl_blk,
- /* dump */ eno_dump,
- /* psize */ vnsize,
- /* flags */ D_DISK,
+static const struct bdevsw vn_bdevsw = {
+ .d_open = vnopen,
+ .d_close = vnclose,
+ .d_strategy = vnstrategy,
+ .d_ioctl = vnioctl_blk,
+ .d_dump = eno_dump,
+ .d_psize = vnsize,
+ .d_type = D_DISK,
};
-static struct cdevsw vn_cdevsw = {
- /* open */ vnopen,
- /* close */ vnclose,
- /* read */ vnread,
- /* write */ vnwrite,
- /* ioctl */ vnioctl_chr,
- /* stop */ eno_stop,
- /* reset */ eno_reset,
- /* ttys */ NULL,
- /* select */ eno_select,
- /* mmap */ eno_mmap,
- /* strategy */ eno_strat,
- /* getc */ eno_getc,
- /* putc */ eno_putc,
- /* flags */ D_DISK,
+static const struct cdevsw vn_cdevsw = {
+ .d_open = vnopen,
+ .d_close = vnclose,
+ .d_read = vnread,
+ .d_write = vnwrite,
+ .d_ioctl = vnioctl_chr,
+ .d_stop = eno_stop,
+ .d_reset = eno_reset,
+ .d_ttys = NULL,
+ .d_select = eno_select,
+ .d_mmap = eno_mmap,
+ .d_strategy = eno_strat,
+ .d_reserved_1 = eno_getc,
+ .d_reserved_2 = eno_putc,
+ .d_type = D_DISK,
};
struct vn_softc {
orig_offset = offset = uio_offset(uio);
while (resid > 0) {
- u_int32_t remainder;
- u_int32_t this_block_number;
- u_int32_t this_block_count;
+ u_int32_t remainder;
+ off_t this_block_number;
+ size_t this_block_count;
off_t this_offset;
user_ssize_t this_resid;
struct vnode * vp;
}
/* read the blocks (or parts thereof) */
- this_offset = (off_t)this_block_number * blocksize + remainder;
+ this_offset = this_block_number * blocksize + remainder;
uio_setoffset(uio, this_offset);
this_resid = this_block_count * blocksize - remainder;
if (this_resid > resid) {
static int
vncopy_block_to_shadow(struct vn_softc * vn, vfs_context_t ctx,
- u_int32_t file_block, u_int32_t shadow_block)
+ off_t file_block, off_t shadow_block)
{
int error;
char * tmpbuf;
}
/* read one block from file at file_block offset */
error = file_io(vn->sc_vp, ctx, UIO_READ,
- tmpbuf, (off_t)file_block * vn->sc_secsize,
+ tmpbuf, file_block * vn->sc_secsize,
vn->sc_secsize, NULL);
if (error) {
goto done;
}
/* write one block to shadow file at shadow_block offset */
error = file_io(vn->sc_shadow_vp, ctx, UIO_WRITE,
- tmpbuf, (off_t)shadow_block * vn->sc_secsize,
+ tmpbuf, shadow_block * vn->sc_secsize,
vn->sc_secsize, NULL);
done:
FREE(tmpbuf, M_TEMP);
while (resid > 0) {
int flags = 0;
- u_int32_t offset_block_number;
- u_int32_t remainder;
- u_int32_t resid_block_count;
- u_int32_t shadow_block_count;
- u_int32_t shadow_block_number;
+ off_t offset_block_number;
+ u_int32_t remainder;
+ size_t resid_block_count;
+ size_t shadow_block_count;
+ off_t shadow_block_number;
user_ssize_t this_resid;
/* figure out which blocks to write */
#endif
}
/* write the blocks (or parts thereof) */
- uio_setoffset(uio, (off_t)
- shadow_block_number * blocksize + remainder);
- this_resid = (off_t)shadow_block_count * blocksize - remainder;
+ uio_setoffset(uio, shadow_block_number * blocksize + remainder);
+ this_resid = shadow_block_count * blocksize - remainder;
if (this_resid >= resid) {
this_resid = resid;
if ((flags & FLAGS_LAST_BLOCK_PARTIAL) != 0) {
/* copy the last block to the shadow */
- u_int32_t d;
- u_int32_t s;
+ off_t d;
+ off_t s;
s = offset_block_number
+ resid_block_count - 1;
error = vncopy_block_to_shadow(vn, ctx, s, d);
if (error) {
printf("vnwrite_shadow: failed to copy"
- " block %u to shadow block %u\n",
+ " block %lld to shadow block %lld\n",
s, d);
break;
}
shadow_block_number);
if (error) {
printf("vnwrite_shadow: failed to"
- " copy block %u to shadow block %u\n",
+ " copy block %lld to shadow block %lld\n",
offset_block_number,
shadow_block_number);
break;
{
u_int32_t blocksize = vn->sc_secsize;
int error = 0;
- u_int32_t offset;
+ off_t offset;
boolean_t read_shadow;
- u_int32_t resid;
+ size_t resid;
u_int32_t start = 0;
offset = buf_blkno(bp);
resid = buf_resid(bp) / blocksize;
while (resid > 0) {
user_ssize_t temp_resid;
- u_int32_t this_offset;
- u_int32_t this_resid;
+ off_t this_offset;
+ size_t this_resid;
struct vnode * vp;
read_shadow = shadow_map_read(vn->sc_shadow_map,
vp = vn->sc_vp;
}
error = file_io(vp, ctx, UIO_READ, base + start,
- (off_t)this_offset * blocksize,
+ this_offset * blocksize,
(user_ssize_t)this_resid * blocksize,
&temp_resid);
if (error) {
offset += this_resid;
start += this_resid * blocksize;
}
- buf_setresid(bp, resid * blocksize);
+ buf_setresid(bp, (uint32_t)(resid * blocksize));
return error;
}
{
u_int32_t blocksize = vn->sc_secsize;
int error = 0;
- u_int32_t offset;
+ off_t offset;
boolean_t shadow_grew;
- u_int32_t resid;
+ size_t resid;
u_int32_t start = 0;
offset = buf_blkno(bp);
resid = buf_resid(bp) / blocksize;
while (resid > 0) {
user_ssize_t temp_resid;
- u_int32_t this_offset;
- u_int32_t this_resid;
+ off_t this_offset;
+ size_t this_resid;
shadow_grew = shadow_map_write(vn->sc_shadow_map,
offset, resid,
}
error = file_io(vn->sc_shadow_vp, ctx, UIO_WRITE,
base + start,
- (off_t)this_offset * blocksize,
+ this_offset * blocksize,
(user_ssize_t)this_resid * blocksize,
&temp_resid);
if (error) {
offset += this_resid;
start += this_resid * blocksize;
}
- buf_setresid(bp, resid * blocksize);
+ buf_setresid(bp, (uint32_t)(resid * blocksize));
return error;
}
iov_base,
(off_t)buf_blkno(bp) * vn->sc_secsize,
buf_resid(bp), &temp_resid);
- buf_setresid(bp, temp_resid);
+ buf_setresid(bp, (uint32_t)temp_resid);
} else {
if (buf_flags(bp) & B_READ) {
error = shadow_read(vn, bp, iov_base, ctx);
* If the request crosses EOF, truncate the request.
*/
if ((blk_num + sz) > 0 && ((u_int64_t)(blk_num + sz)) > vn->sc_size) {
- buf_setcount(bp, (vn->sc_size - blk_num) * vn->sc_secsize);
+ buf_setcount(bp, (uint32_t)((vn->sc_size - blk_num) * vn->sc_secsize));
buf_setresid(bp, buf_count(bp));
}
vp = vn->sc_vp;