• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/xnu-2782.1.97/bsd/dev/vn/

Lines Matching refs:vn

66  * from: Utah Hdr: vn.c 1.13 94/04/02
68 * from: @(#)vn.c 8.6 (Berkeley) 4/1/94
69 * $FreeBSD: src/sys/dev/vn/vn.c,v 1.105.2.4 2001/11/18 07:11:00 dillon Exp $
173 u_int64_t sc_size; /* size of vn, sc_secsize scale */
196 #define IFOPT(vn,opt) if (((vn)->sc_options|vn_options) & (opt))
197 #define TESTOPT(vn,opt) (((vn)->sc_options|vn_options) & (opt))
200 static void vnclear (struct vn_softc *vn, vfs_context_t ctx);
206 vniocattach_file(struct vn_softc *vn,
212 vniocattach_shadow(struct vn_softc * vn,
233 struct vn_softc *vn;
240 vn = vn_table + unit;
241 if ((flags & FWRITE) && (vn->sc_flags & VNF_READONLY))
289 vnread_shadow(struct vn_softc * vn, struct uio *uio, int ioflag,
292 u_int32_t blocksize = vn->sc_secsize;
312 if (shadow_map_read(vn->sc_shadow_map,
316 vp = vn->sc_shadow_vp;
319 vp = vn->sc_vp;
338 printf("vn device: vnread_shadow zero length read\n");
350 vncopy_block_to_shadow(struct vn_softc * vn, vfs_context_t ctx,
356 tmpbuf = _MALLOC(vn->sc_secsize, M_TEMP, M_WAITOK);
361 error = file_io(vn->sc_vp, ctx, UIO_READ,
362 tmpbuf, (off_t)file_block * vn->sc_secsize,
363 vn->sc_secsize, NULL);
368 error = file_io(vn->sc_shadow_vp, ctx, UIO_WRITE,
369 tmpbuf, (off_t)shadow_block * vn->sc_secsize,
370 vn->sc_secsize, NULL);
382 vnwrite_shadow(struct vn_softc * vn, struct uio *uio, int ioflag,
385 u_int32_t blocksize = vn->sc_secsize;
408 && !shadow_map_is_written(vn->sc_shadow_map,
414 && !shadow_map_is_written(vn->sc_shadow_map,
421 if (shadow_map_write(vn->sc_shadow_map,
429 size = (off_t)shadow_map_shadow_size(vn->sc_shadow_map)
430 * vn->sc_secsize;
431 vnode_setsize(vn->sc_shadow_vp, size, IO_SYNC, ctx);
449 error = vncopy_block_to_shadow(vn, ctx, s, d);
461 error = vncopy_block_to_shadow(vn, ctx,
472 error = VNOP_WRITE(vn->sc_shadow_vp, uio, ioflag, ctx);
479 printf("vn device: vnwrite_shadow zero length write\n");
498 struct vn_softc * vn;
506 vn = vn_table + unit;
507 if ((vn->sc_flags & VNF_INITED) == 0) {
513 context.vc_ucred = vn->sc_cred;
515 error = vnode_getwithvid(vn->sc_vp, vn->sc_vid);
519 vnclear(vn, &context);
530 if (offset >= (off_t)vn->sc_fsize) {
531 if (offset > (off_t)vn->sc_fsize) {
539 if ((offset + resid) > (off_t)vn->sc_fsize) {
540 resid = vn->sc_fsize - offset;
544 if (vn->sc_shadow_vp != NULL) {
545 error = vnode_getwithvid(vn->sc_shadow_vp,
546 vn->sc_shadow_vid);
550 vnode_put(vn->sc_vp);
551 vnclear(vn, &context);
554 error = vnread_shadow(vn, uio, ioflag, &context);
555 vnode_put(vn->sc_shadow_vp);
557 error = VNOP_READ(vn->sc_vp, uio, ioflag, &context);
559 vnode_put(vn->sc_vp);
572 struct vn_softc * vn;
580 vn = vn_table + unit;
581 if ((vn->sc_flags & VNF_INITED) == 0) {
585 if (vn->sc_flags & VNF_READONLY) {
591 context.vc_ucred = vn->sc_cred;
593 error = vnode_getwithvid(vn->sc_vp, vn->sc_vid);
597 vnclear(vn, &context);
607 if (offset >= (off_t)vn->sc_fsize) {
608 if (offset > (off_t)vn->sc_fsize) {
616 if ((offset + resid) > (off_t)vn->sc_fsize) {
617 resid = (off_t)vn->sc_fsize - offset;
621 if (vn->sc_shadow_vp != NULL) {
622 error = vnode_getwithvid(vn->sc_shadow_vp,
623 vn->sc_shadow_vid);
627 vnode_put(vn->sc_vp);
628 vnclear(vn, &context);
631 error = vnwrite_shadow(vn, uio, ioflag, &context);
632 vnode_put(vn->sc_shadow_vp);
634 error = VNOP_WRITE(vn->sc_vp, uio, ioflag, &context);
636 vnode_put(vn->sc_vp);
642 shadow_read(struct vn_softc * vn, struct buf * bp, char * base,
645 u_int32_t blocksize = vn->sc_secsize;
660 read_shadow = shadow_map_read(vn->sc_shadow_map,
664 vp = vn->sc_shadow_vp;
667 vp = vn->sc_vp;
678 printf("vn device: shadow_read zero length read\n");
690 shadow_write(struct vn_softc * vn, struct buf * bp, char * base,
693 u_int32_t blocksize = vn->sc_secsize;
707 shadow_grew = shadow_map_write(vn->sc_shadow_map,
714 size = (off_t)shadow_map_shadow_size(vn->sc_shadow_map)
716 vnode_setsize(vn->sc_shadow_vp, size, IO_SYNC, ctx);
719 error = file_io(vn->sc_shadow_vp, ctx, UIO_WRITE,
729 printf("vn device: shadow_write zero length write\n");
741 vn_readwrite_io(struct vn_softc * vn, struct buf * bp, vfs_context_t ctx)
748 panic("vn device: buf_map failed");
751 if (vn->sc_shadow_vp == NULL) {
754 error = file_io(vn->sc_vp, ctx,
757 (off_t)buf_blkno(bp) * vn->sc_secsize,
763 error = shadow_read(vn, bp, iov_base, ctx);
765 error = shadow_write(vn, bp, iov_base, ctx);
775 struct vn_softc *vn;
783 vn = vn_table + vnunit(buf_device(bp));
784 if ((vn->sc_flags & VNF_INITED) == 0) {
790 context.vc_ucred = vn->sc_cred;
798 if (buf_count(bp) % vn->sc_secsize != 0) {
802 sz = howmany(buf_count(bp), vn->sc_secsize);
808 if (blk_num >= 0 && (u_int64_t)blk_num >= vn->sc_size) {
809 if (blk_num > 0 && (u_int64_t)blk_num > vn->sc_size) {
817 if ((blk_num + sz) > 0 && ((u_int64_t)(blk_num + sz)) > vn->sc_size) {
818 buf_setcount(bp, (vn->sc_size - blk_num) * vn->sc_secsize);
821 vp = vn->sc_vp;
827 error = vnode_getwithvid(vp, vn->sc_vid);
831 vnclear(vn, &context);
834 shadow_vp = vn->sc_shadow_vp;
837 vn->sc_shadow_vid);
841 vnode_put(vn->sc_vp);
842 vnclear(vn, &context);
847 error = vn_readwrite_io(vn, bp, &context);
867 struct vn_softc *vn;
882 vn = vn_table + unit;
889 context.vc_ucred = vn->sc_cred;
912 if ((vn->sc_flags & VNF_INITED) == 0) {
921 if (vn->sc_vp != NULL)
922 vfs_ioattr(vnode_mount(vn->sc_vp), &ioattr);
931 *o = ioattr.io_maxreadcnt / vn->sc_secsize;
934 *o = ioattr.io_maxwritecnt / vn->sc_secsize;
955 *f = vn->sc_secsize;
967 if (vn->sc_shadow_vp != NULL) {
968 if (*f == (unsigned)vn->sc_secsize) {
975 vn->sc_secsize = *f;
977 vn->sc_size = vn->sc_fsize / vn->sc_secsize;
983 *f = vn->sc_size;
986 *o = vn->sc_size;
995 if (vn->sc_shadow_vp != NULL) {
999 if (vn->sc_vp == NULL) {
1013 error = vniocattach_shadow(vn, viop, dev, 0, p);
1028 if (vn->sc_flags & VNF_INITED) {
1041 error = vniocattach_file(vn, viop, dev, 0, p);
1066 vnclear(vn, &context);
1080 vn->sc_options |= *f;
1081 *f = vn->sc_options;
1085 vn->sc_options &= ~(*f);
1086 *f = vn->sc_options;
1117 vniocattach_file(struct vn_softc *vn,
1180 vn->sc_secsize = DEV_BSIZE;
1181 vn->sc_fsize = file_size;
1182 vn->sc_size = file_size / vn->sc_secsize;
1183 vn->sc_vp = nd.ni_vp;
1184 vn->sc_vid = vnode_vid(nd.ni_vp);
1185 vn->sc_open_flags = flags;
1186 vn->sc_cred = cred;
1188 vn->sc_cdev = devfs_make_node(cdev, DEVFS_CHAR,
1192 vn->sc_flags |= VNF_INITED;
1194 vn->sc_flags |= VNF_READONLY;
1201 vniocattach_shadow(struct vn_softc *vn, struct vn_ioctl_64 *vniop,
1231 map = shadow_map_create(vn->sc_fsize, file_size,
1232 0, vn->sc_secsize);
1236 vn->sc_shadow_vp = NULL;
1239 vn->sc_shadow_vp = nd.ni_vp;
1240 vn->sc_shadow_vid = vnode_vid(nd.ni_vp);
1241 vn->sc_shadow_vp->v_flag |= VNOCACHE_DATA;
1242 vn->sc_shadow_map = map;
1243 vn->sc_flags &= ~VNF_READONLY; /* we're now read/write */
1254 struct vn_softc * vn;
1260 vn = vn_table + ROOT_IMAGE_UNIT;
1263 snprintf(devname, 16, "vn%d", ROOT_IMAGE_UNIT);
1264 error = vniocattach_file(vn, &vnio, *dev_p, 1, current_proc());
1293 vnclear(struct vn_softc *vn, vfs_context_t ctx)
1295 if (vn->sc_vp != NULL) {
1297 (void)vn_close(vn->sc_vp, vn->sc_open_flags, ctx);
1298 vn->sc_vp = NULL;
1300 if (vn->sc_shadow_vp != NULL) {
1302 (void)vn_close(vn->sc_shadow_vp, FREAD | FWRITE, ctx);
1303 vn->sc_shadow_vp = NULL;
1305 if (vn->sc_shadow_map != NULL) {
1306 shadow_map_free(vn->sc_shadow_map);
1307 vn->sc_shadow_map = NULL;
1309 vn->sc_flags &= ~(VNF_INITED | VNF_READONLY);
1310 if (vn->sc_cred) {
1311 kauth_cred_unref(&vn->sc_cred);
1313 vn->sc_size = 0;
1314 vn->sc_fsize = 0;
1315 if (vn->sc_cdev) {
1316 devfs_remove(vn->sc_cdev);
1317 vn->sc_cdev = NULL;
1325 struct vn_softc *vn;
1333 vn = vn_table + unit;
1334 if ((vn->sc_flags & VNF_INITED) == 0)
1337 secsize = vn->sc_secsize;
1378 0600, "vn%d",