View | Details | Raw Unified | Return to bug 245865 | Differences between
and this patch

Collapse All | Expand All

(-)b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs.h (-4 / +5 lines)
Lines 9-15 Link Here
9
 /*
9
 /*
10
  * Copyright (C) 2010-2020 Oracle Corporation
10
  * Copyright (C) 2010-2020 Oracle Corporation
11
  *
11
  *
12
@@ -24,72 +19,377 @@
12
@@ -24,72 +19,378 @@
13
 #define VBOXVFS_VFSNAME "vboxvfs"
13
 #define VBOXVFS_VFSNAME "vboxvfs"
14
 #define VBOXVFS_VERSION 1
14
 #define VBOXVFS_VERSION 1
15
 
15
 
Lines 240-245 Link Here
240
+	struct vnode		*sf_vnode;	/* vnode if active */
240
+	struct vnode		*sf_vnode;	/* vnode if active */
241
+	sfp_file_t		*sf_file;	/* non NULL if open */
241
+	sfp_file_t		*sf_file;	/* non NULL if open */
242
+	struct vboxfs_node	*sf_parent;	/* parent sfnode of this one */
242
+	struct vboxfs_node	*sf_parent;	/* parent sfnode of this one */
243
+	uint32_t		sf_opencnt;	/* sf_file reference counter */
243
+	uint16_t		sf_children;	/* number of children sfnodes */
244
+	uint16_t		sf_children;	/* number of children sfnodes */
244
+	uint8_t			sf_type;	/* VDIR or VREG */
245
+	uint8_t			sf_type;	/* VDIR or VREG */
245
+	uint8_t			sf_vpstate;	/* XXX: ADD COMMENT */
246
+	uint8_t			sf_vpstate;	/* XXX: ADD COMMENT */
Lines 248-254 Link Here
248
+	uint64_t		sf_stat_time;	/* last-modified time of sf_stat */
249
+	uint64_t		sf_stat_time;	/* last-modified time of sf_stat */
249
+	sffs_dirents_t		*sf_dir_list;	/* list of entries for this directory */
250
+	sffs_dirents_t		*sf_dir_list;	/* list of entries for this directory */
250
+
251
+
251
+	/* interlock to protect sf_vpstate */
252
+	/* interlock to protect sf_vpstate, sf_file and sf_opencnt */
252
+	struct mtx		sf_interlock;
253
+	struct mtx		sf_interlock;
253
+};
254
+};
254
+
255
+
Lines 371-377 Link Here
371
+extern int sfprov_get_fsinfo(sfp_mount_t *, sffs_fsinfo_t *);
372
+extern int sfprov_get_fsinfo(sfp_mount_t *, sffs_fsinfo_t *);
372
+
373
+
373
+extern int sfprov_create(sfp_mount_t *, char *path, mode_t mode,
374
+extern int sfprov_create(sfp_mount_t *, char *path, mode_t mode,
374
+    sfp_file_t **fp, sffs_stat_t *stat);
375
+    sffs_stat_t *stat);
375
+extern int sfprov_open(sfp_mount_t *, char *path, sfp_file_t **fp);
376
+extern int sfprov_open(sfp_mount_t *, char *path, sfp_file_t **fp);
376
+extern int sfprov_close(sfp_file_t *fp);
377
+extern int sfprov_close(sfp_file_t *fp);
377
+extern int sfprov_read(sfp_file_t *, char * buffer, uint64_t offset,
378
+extern int sfprov_read(sfp_file_t *, char * buffer, uint64_t offset,
Lines 401-407 Link Here
401
+extern int sfprov_trunc(sfp_mount_t *, char *);
402
+extern int sfprov_trunc(sfp_mount_t *, char *);
402
+extern int sfprov_remove(sfp_mount_t *, char *path, u_int is_link);
403
+extern int sfprov_remove(sfp_mount_t *, char *path, u_int is_link);
403
+extern int sfprov_mkdir(sfp_mount_t *, char *path, mode_t mode,
404
+extern int sfprov_mkdir(sfp_mount_t *, char *path, mode_t mode,
404
+    sfp_file_t **fp, sffs_stat_t *stat);
405
+    sffs_stat_t *stat);
405
+extern int sfprov_rmdir(sfp_mount_t *, char *path);
406
+extern int sfprov_rmdir(sfp_mount_t *, char *path);
406
+extern int sfprov_rename(sfp_mount_t *, char *from, char *to, u_int is_dir);
407
+extern int sfprov_rename(sfp_mount_t *, char *from, char *to, u_int is_dir);
407
+
408
+
(-)b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__prov.c (-14 / +5 lines)
Lines 1-6 Link Here
1
--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c.orig	2020-06-26 09:59:35 UTC
1
--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c.orig	2024-08-15 13:18:37.777504000 +0900
2
+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c
2
+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_prov.c	2024-08-15 13:18:37.777446000 +0900
3
@@ -0,0 +1,1021 @@
3
@@ -0,0 +1,1012 @@
4
+/*
4
+/*
5
+ * Copyright (C) 2008-2016 Oracle Corporation
5
+ * Copyright (C) 2008-2016 Oracle Corporation
6
+ *
6
+ *
Lines 309-315 Link Here
309
+	sfp_mount_t *mnt,
309
+	sfp_mount_t *mnt,
310
+	char *path,
310
+	char *path,
311
+	mode_t mode,
311
+	mode_t mode,
312
+	sfp_file_t **fp,
313
+	sffs_stat_t *stat)
312
+	sffs_stat_t *stat)
314
+{
313
+{
315
+	int rc;
314
+	int rc;
Lines 334-343 Link Here
334
+			return (EEXIST);
333
+			return (EEXIST);
335
+		return (ENOENT);
334
+		return (ENOENT);
336
+	}
335
+	}
337
+	newfp = malloc(sizeof(sfp_file_t), M_VBOXVFS, M_WAITOK | M_ZERO);
336
+	(void)VbglR0SfClose(&vbox_client, &mnt->map, parms.Handle);
338
+	newfp->handle = parms.Handle;
339
+	newfp->map = mnt->map;
340
+	*fp = newfp;
341
+	sfprov_stat_from_info(stat, &parms.Info);
337
+	sfprov_stat_from_info(stat, &parms.Info);
342
+	return (0);
338
+	return (0);
343
+}
339
+}
Lines 714-727 Link Here
714
+	sfp_mount_t *mnt,
710
+	sfp_mount_t *mnt,
715
+	char *path,
711
+	char *path,
716
+	mode_t mode,
712
+	mode_t mode,
717
+	sfp_file_t **fp,
718
+	sffs_stat_t *stat)
713
+	sffs_stat_t *stat)
719
+{
714
+{
720
+	int rc;
715
+	int rc;
721
+	SHFLCREATEPARMS parms;
716
+	SHFLCREATEPARMS parms;
722
+	SHFLSTRING *str;
717
+	SHFLSTRING *str;
723
+	int size;
718
+	int size;
724
+	sfp_file_t *newfp;
725
+
719
+
726
+	str = sfprov_string(path, &size);
720
+	str = sfprov_string(path, &size);
727
+	parms.Handle = SHFL_HANDLE_NIL;
721
+	parms.Handle = SHFL_HANDLE_NIL;
Lines 739-748 Link Here
739
+			return (EEXIST);
733
+			return (EEXIST);
740
+		return (ENOENT);
734
+		return (ENOENT);
741
+	}
735
+	}
742
+	newfp = malloc(sizeof(sfp_file_t), M_VBOXVFS, M_WAITOK | M_ZERO);
736
+	(void)VbglR0SfClose(&vbox_client, &mnt->map, parms.Handle);
743
+	newfp->handle = parms.Handle;
744
+	newfp->map = mnt->map;
745
+	*fp = newfp;
746
+	sfprov_stat_from_info(stat, &parms.Info);
737
+	sfprov_stat_from_info(stat, &parms.Info);
747
+	return (0);
738
+	return (0);
748
+}
739
+}
(-)b/emulators/virtualbox-ose/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c (-89 / +140 lines)
Lines 1-6 Link Here
1
--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c.orig	2022-07-19 20:51:58 UTC
1
--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c.orig	2023-07-12 15:59:35 UTC
2
+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c
2
+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c
3
@@ -14,228 +14,1364 @@
3
@@ -14,228 +14,1416 @@
4
  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4
  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5
  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5
  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
6
  */
6
  */
Lines 83-89 Link Here
83
+static vop_fsync_t	vboxfs_fsync;
83
+static vop_fsync_t	vboxfs_fsync;
84
+static vop_remove_t	vboxfs_remove;
84
+static vop_remove_t	vboxfs_remove;
85
+static vop_link_t	vboxfs_link;
85
+static vop_link_t	vboxfs_link;
86
+static vop_cachedlookup_t	vboxfs_lookup;
86
+static vop_lookup_t	vboxfs_lookup;
87
+static vop_cachedlookup_t	vboxfs_cachedlookup;
87
+static vop_rename_t	vboxfs_rename;
88
+static vop_rename_t	vboxfs_rename;
88
+static vop_mkdir_t	vboxfs_mkdir;
89
+static vop_mkdir_t	vboxfs_mkdir;
89
+static vop_rmdir_t	vboxfs_rmdir;
90
+static vop_rmdir_t	vboxfs_rmdir;
Lines 140-147 Link Here
140
+	.vop_inactive	= vboxfs_inactive,
141
+	.vop_inactive	= vboxfs_inactive,
141
+	.vop_ioctl	= vboxfs_ioctl,
142
+	.vop_ioctl	= vboxfs_ioctl,
142
+	.vop_link	= vboxfs_link,
143
+	.vop_link	= vboxfs_link,
143
+	.vop_lookup	= vfs_cache_lookup,
144
+	.vop_lookup	= vboxfs_lookup,
144
+	.vop_cachedlookup	= vboxfs_lookup,
145
+	.vop_cachedlookup	= vboxfs_cachedlookup,
145
+	.vop_mkdir	= vboxfs_mkdir,
146
+	.vop_mkdir	= vboxfs_mkdir,
146
+	.vop_mknod	= VOP_EOPNOTSUPP,
147
+	.vop_mknod	= VOP_EOPNOTSUPP,
147
+	.vop_open	= vboxfs_open,
148
+	.vop_open	= vboxfs_open,
Lines 462-474 Link Here
462
 {
463
 {
463
-    return 0;
464
-    return 0;
464
+	char *p;
465
+	char *p;
466
+	size_t dstsz;
465
+
467
+
466
+	if (len <= 2 && tail[0] == '.' && (len == 1 || tail[1] == '.'))
468
+	if (len <= 2 && tail[0] == '.' && (len == 1 || tail[1] == '.'))
467
+		panic("construct path for %s", tail);
469
+		panic("construct path for %s", tail);
468
+	p = malloc(strlen(node->sf_path) + 1 + len + 1, M_VBOXVFS, M_WAITOK);
470
+	dstsz = strlen(node->sf_path) + 1 + len + 1;
471
+	p = malloc(dstsz, M_VBOXVFS, M_WAITOK);
469
+	strcpy(p, node->sf_path);
472
+	strcpy(p, node->sf_path);
470
+	strcat(p, "/");
473
+	strcat(p, "/");
471
+	strcat(p, tail);
474
+	strlcat(p, tail, dstsz);
472
+	return (p);
475
+	return (p);
473
 }
476
 }
474
 
477
 
Lines 531-568 Link Here
531
 
534
 
532
-static int vboxvfs_symlink(struct vop_symlink_args *ap)
535
-static int vboxvfs_symlink(struct vop_symlink_args *ap)
533
+static int
536
+static int
534
+vboxfs_open(struct vop_open_args *ap)
537
+vboxfs_get_sfp_file(struct vboxfs_node *np)
535
 {
538
 {
536
-    return EOPNOTSUPP;
539
-    return EOPNOTSUPP;
537
+	struct vboxfs_node *np;
538
+	sfp_file_t *fp;
540
+	sfp_file_t *fp;
539
+	int error;
541
+	int error;
540
+
542
+
543
+	fp = NULL;
544
+	VBOXFS_NODE_LOCK(np);
545
+	for (;;) {
546
+		if (np->sf_file != NULL) {
547
+			if (fp != NULL)
548
+				(void) sfprov_close(fp);
549
+			np->sf_opencnt++;
550
+			fp = np->sf_file;
551
+			break;
552
+		} else if (fp != NULL) {
553
+			np->sf_file = fp;
554
+			KASSERT(np->sf_opencnt == 0,
555
+				("np %p opencnt (%d) must be zero.",
556
+				 np, np->sf_opencnt));
557
+			np->sf_opencnt = 1;
558
+			break;
559
+		}
560
+		VBOXFS_NODE_UNLOCK(np);
561
+		error = sfprov_open(np->vboxfsmp->sf_handle, np->sf_path, &fp);
562
+		if (error != 0)
563
+			return (error);
564
+		VBOXFS_NODE_LOCK(np);
565
+	}
566
+	VBOXFS_NODE_UNLOCK(np);
567
+
568
+	return (0);
569
 }
570
 
571
-static int vboxvfs_mknod(struct vop_mknod_args *ap)
572
+static void
573
+vboxfs_put_sfp_file(struct vboxfs_node *np)
574
 {
575
-    return EOPNOTSUPP;
576
+	VBOXFS_NODE_LOCK(np);
577
+	np->sf_opencnt--;
578
+	if (np->sf_opencnt == 0) {
579
+		(void) sfprov_close(np->sf_file);
580
+		np->sf_file = NULL;
581
+	}
582
+	VBOXFS_NODE_UNLOCK(np);
583
 }
584
 
585
-static int vboxvfs_mkdir(struct vop_mkdir_args *ap)
586
+static int
587
+vboxfs_open(struct vop_open_args *ap)
588
 {
589
-    return 0;
590
+	struct vboxfs_node *np;
591
+	int error;
592
+
541
+	MPASS(VOP_ISLOCKED(vp));
593
+	MPASS(VOP_ISLOCKED(vp));
542
+
594
+
543
+	np = VP_TO_VBOXFS_NODE(ap->a_vp);
595
+	np = VP_TO_VBOXFS_NODE(ap->a_vp);
544
+	error = sfprov_open(np->vboxfsmp->sf_handle, np->sf_path, &fp);
596
+	error = vboxfs_get_sfp_file(np);
545
+	if (error != 0)
597
+	if (error != 0)
546
+		goto out;
598
+		goto out;
547
+
599
+
548
+	np->sf_file = fp;
549
+	vnode_create_vobject(ap->a_vp, 0, ap->a_td);
600
+	vnode_create_vobject(ap->a_vp, 0, ap->a_td);
550
+
551
+out:
601
+out:
552
+	MPASS(VOP_ISLOCKED(vp));
602
+	MPASS(VOP_ISLOCKED(vp));
553
+
603
+
554
+	return (error);
604
+	return (error);
555
 }
605
 }
556
 
606
 
557
-static int vboxvfs_mknod(struct vop_mknod_args *ap)
607
-static int vboxvfs_rmdir(struct vop_rmdir_args *ap)
558
+static void
608
+static void
559
+vfsnode_invalidate_stat_cache(struct vboxfs_node *np)
609
+vfsnode_invalidate_stat_cache(struct vboxfs_node *np)
560
 {
610
 {
561
-    return EOPNOTSUPP;
611
-    return 0;
562
+	np->sf_stat_time = 0;
612
+	np->sf_stat_time = 0;
563
 }
613
 }
564
 
614
 
565
-static int vboxvfs_mkdir(struct vop_mkdir_args *ap)
615
-static int vboxvfs_readdir(struct vop_readdir_args *ap)
566
+static int
616
+static int
567
+vboxfs_close(struct vop_close_args *ap)
617
+vboxfs_close(struct vop_close_args *ap)
568
 {
618
 {
Lines 585-599 Link Here
585
+
635
+
586
+	vfsnode_invalidate_stat_cache(np);
636
+	vfsnode_invalidate_stat_cache(np);
587
+
637
+
588
+	if (np->sf_file != NULL && vp->v_usecount <= 1) {
638
+	vboxfs_put_sfp_file(np);
589
+		(void) sfprov_close(np->sf_file);
590
+		np->sf_file = NULL;
591
+	}
592
+
639
+
593
+	return (0);
640
+	return (0);
594
 }
641
 }
595
 
642
 
596
-static int vboxvfs_rmdir(struct vop_rmdir_args *ap)
643
-static int vboxvfs_fsync(struct vop_fsync_args *ap)
597
+static int
644
+static int
598
+vboxfs_getattr(struct vop_getattr_args *ap)
645
+vboxfs_getattr(struct vop_getattr_args *ap)
599
 {
646
 {
Lines 674-680 Link Here
674
+	return (error);
721
+	return (error);
675
 }
722
 }
676
 
723
 
677
-static int vboxvfs_readdir(struct vop_readdir_args *ap)
724
-static int vboxvfs_print (struct vop_print_args *ap)
678
+static int
725
+static int
679
+vboxfs_setattr(struct vop_setattr_args *ap)
726
+vboxfs_setattr(struct vop_setattr_args *ap)
680
 {
727
 {
Lines 738-744 Link Here
738
+	return (error);
785
+	return (error);
739
 }
786
 }
740
 
787
 
741
-static int vboxvfs_fsync(struct vop_fsync_args *ap)
788
-static int vboxvfs_pathconf (struct vop_pathconf_args *ap)
742
+#define blkoff(vboxfsmp, loc)	((loc) & (vboxfsmp)->bmask)
789
+#define blkoff(vboxfsmp, loc)	((loc) & (vboxfsmp)->bmask)
743
+
790
+
744
+static int
791
+static int
Lines 776-781 Link Here
776
+	if (tmpbuf == 0)
823
+	if (tmpbuf == 0)
777
+		return (ENOMEM);
824
+		return (ENOMEM);
778
+
825
+
826
+	/*
827
+	 * XXX VOP_READ() is called without VOP_OPEN() on exec case.
828
+	 * We need to ensure the file is opened here.
829
+	 */
830
+	error = vboxfs_get_sfp_file(np);
831
+	if (error != 0)	/* Maybe removed on the host. */
832
+		return (EIO);
779
+	do {
833
+	do {
780
+		offset = uio->uio_offset;
834
+		offset = uio->uio_offset;
781
+		done = bytes = min(PAGE_SIZE, uio->uio_resid);
835
+		done = bytes = min(PAGE_SIZE, uio->uio_resid);
Lines 784-789 Link Here
784
+		if (error == 0 && done > 0)
838
+		if (error == 0 && done > 0)
785
+			error = uiomove(tmpbuf, done, uio);
839
+			error = uiomove(tmpbuf, done, uio);
786
+	} while (error == 0 && uio->uio_resid > 0 && done > 0);
840
+	} while (error == 0 && uio->uio_resid > 0 && done > 0);
841
+	vboxfs_put_sfp_file(np);
787
+
842
+
788
+	contigfree(tmpbuf, PAGE_SIZE, M_DEVBUF);
843
+	contigfree(tmpbuf, PAGE_SIZE, M_DEVBUF);
789
+
844
+
Lines 794-800 Link Here
794
+	return (error);
849
+	return (error);
795
 }
850
 }
796
 
851
 
797
-static int vboxvfs_print (struct vop_print_args *ap)
852
-static int vboxvfs_strategy (struct vop_strategy_args *ap)
798
+static int
853
+static int
799
+vboxfs_write(struct vop_write_args *ap)
854
+vboxfs_write(struct vop_write_args *ap)
800
 {
855
 {
Lines 855-865 Link Here
855
+	return (error);
910
+	return (error);
856
 }
911
 }
857
 
912
 
858
-static int vboxvfs_pathconf (struct vop_pathconf_args *ap)
913
-static int vboxvfs_ioctl(struct vop_ioctl_args *ap)
859
+static int
914
+static int
860
+vboxfs_create(struct vop_create_args *ap)
915
+vboxfs_create(struct vop_create_args *ap)
861
 {
916
 {
862
-    return 0;
917
-    return ENOTTY;
863
+	struct vnode *dvp = ap->a_dvp;
918
+	struct vnode *dvp = ap->a_dvp;
864
+	struct vnode **vpp = ap->a_vpp;
919
+	struct vnode **vpp = ap->a_vpp;
865
+	struct componentname *cnp = ap->a_cnp;
920
+	struct componentname *cnp = ap->a_cnp;
Lines 867-873 Link Here
867
+	sffs_stat_t	stat;
922
+	sffs_stat_t	stat;
868
+	char	*fullpath = NULL;
923
+	char	*fullpath = NULL;
869
+	struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(dvp);
924
+	struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(dvp);
870
+	sfp_file_t *fp;
871
+	int error;
925
+	int error;
872
+	struct 	vboxfs_mnt *vboxfsmp = dir->vboxfsmp;
926
+	struct 	vboxfs_mnt *vboxfsmp = dir->vboxfsmp;
873
+
927
+
Lines 875-881 Link Here
875
+
929
+
876
+	fullpath = sfnode_construct_path(dir, cnp->cn_nameptr, cnp->cn_namelen);
930
+	fullpath = sfnode_construct_path(dir, cnp->cn_nameptr, cnp->cn_namelen);
877
+	error = sfprov_create(dir->vboxfsmp->sf_handle, fullpath, vap->va_mode,
931
+	error = sfprov_create(dir->vboxfsmp->sf_handle, fullpath, vap->va_mode,
878
+	    &fp, &stat);
932
+	    &stat);
879
+
933
+
880
+	if (error)
934
+	if (error)
881
+		goto out;
935
+		goto out;
Lines 895-901 Link Here
895
+	return (error);
949
+	return (error);
896
 }
950
 }
897
 
951
 
898
-static int vboxvfs_strategy (struct vop_strategy_args *ap)
952
-static int vboxvfs_getextattr(struct vop_getextattr_args *ap)
899
+static int
953
+static int
900
+vboxfs_remove(struct vop_remove_args *ap)
954
+vboxfs_remove(struct vop_remove_args *ap)
901
 {
955
 {
Lines 914-935 Link Here
914
+	np = VP_TO_VBOXFS_NODE(vp);
968
+	np = VP_TO_VBOXFS_NODE(vp);
915
+	dir = VP_TO_VBOXFS_NODE(vp);
969
+	dir = VP_TO_VBOXFS_NODE(vp);
916
+
970
+
917
+	/*
918
+	 * If anything else is using this vnode, then fail the remove.
919
+	 * Why?  Windows hosts can't sfprov_remove() a file that is open,
920
+	 * so we have to sfprov_close() it first.
921
+	 * There is no errno for this - since it's not a problem on UNIX,
922
+	 * but ETXTBSY is the closest.
923
+	 */
924
+	if (np->sf_file != NULL) {
925
+		if (vp->v_usecount > 1) {
926
+			error = ETXTBSY;
927
+			goto out;
928
+		}
929
+		sfprov_close(np->sf_file);
930
+		np->sf_file = NULL;
931
+	}
932
+
933
+	error = sfprov_remove(np->vboxfsmp->sf_handle, np->sf_path,
971
+	error = sfprov_remove(np->vboxfsmp->sf_handle, np->sf_path,
934
+	    np->sf_type == VLNK);
972
+	    np->sf_type == VLNK);
935
+
973
+
Lines 945-955 Link Here
945
+	return (error);
983
+	return (error);
946
 }
984
 }
947
 
985
 
948
-static int vboxvfs_ioctl(struct vop_ioctl_args *ap)
986
-static int vboxvfs_advlock(struct vop_advlock_args *ap)
949
+static int
987
+static int
950
+vboxfs_rename(struct vop_rename_args *ap)
988
+vboxfs_rename(struct vop_rename_args *ap)
951
 {
989
 {
952
-    return ENOTTY;
990
-    return 0;
953
+	struct vnode *fvp;
991
+	struct vnode *fvp;
954
+	struct vnode *fdvp;
992
+	struct vnode *fdvp;
955
+	struct vnode *tvp;
993
+	struct vnode *tvp;
Lines 989-995 Link Here
989
+	return (ret);
1027
+	return (ret);
990
 }
1028
 }
991
 
1029
 
992
-static int vboxvfs_getextattr(struct vop_getextattr_args *ap)
1030
-static int vboxvfs_lookup(struct vop_lookup_args *ap)
993
+static int
1031
+static int
994
+vboxfs_link(struct vop_link_args *ap)
1032
+vboxfs_link(struct vop_link_args *ap)
995
 {
1033
 {
Lines 997-1003 Link Here
997
+	return (EOPNOTSUPP);
1035
+	return (EOPNOTSUPP);
998
 }
1036
 }
999
 
1037
 
1000
-static int vboxvfs_advlock(struct vop_advlock_args *ap)
1038
-static int vboxvfs_inactive(struct vop_inactive_args *ap)
1001
+static int
1039
+static int
1002
+vboxfs_symlink(struct vop_symlink_args *ap)
1040
+vboxfs_symlink(struct vop_symlink_args *ap)
1003
 {
1041
 {
Lines 1032-1038 Link Here
1032
+	return (error);
1070
+	return (error);
1033
 }
1071
 }
1034
 
1072
 
1035
-static int vboxvfs_lookup(struct vop_lookup_args *ap)
1073
-static int vboxvfs_reclaim(struct vop_reclaim_args *ap)
1036
+static int
1074
+static int
1037
+vboxfs_mkdir(struct vop_mkdir_args *ap)
1075
+vboxfs_mkdir(struct vop_mkdir_args *ap)
1038
 {
1076
 {
Lines 1044-1050 Link Here
1044
+	sffs_stat_t	stat;
1082
+	sffs_stat_t	stat;
1045
+	char	*fullpath = NULL;
1083
+	char	*fullpath = NULL;
1046
+	struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(dvp);
1084
+	struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(dvp);
1047
+	sfp_file_t *fp;
1048
+	int error;
1085
+	int error;
1049
+	struct 	vboxfs_mnt *vboxfsmp = dir->vboxfsmp;
1086
+	struct 	vboxfs_mnt *vboxfsmp = dir->vboxfsmp;
1050
+
1087
+
Lines 1052-1058 Link Here
1052
+
1089
+
1053
+	fullpath = sfnode_construct_path(dir, cnp->cn_nameptr, cnp->cn_namelen);
1090
+	fullpath = sfnode_construct_path(dir, cnp->cn_nameptr, cnp->cn_namelen);
1054
+	error = sfprov_mkdir(dir->vboxfsmp->sf_handle, fullpath, vap->va_mode,
1091
+	error = sfprov_mkdir(dir->vboxfsmp->sf_handle, fullpath, vap->va_mode,
1055
+	    &fp, &stat);
1092
+	    &stat);
1056
+
1093
+
1057
+	if (error)
1094
+	if (error)
1058
+		goto out;
1095
+		goto out;
Lines 1069-1075 Link Here
1069
+	return (error);
1106
+	return (error);
1070
 }
1107
 }
1071
 
1108
 
1072
-static int vboxvfs_inactive(struct vop_inactive_args *ap)
1109
-static int vboxvfs_getpages(struct vop_getpages_args *ap)
1073
+static int
1110
+static int
1074
+vboxfs_rmdir(struct vop_rmdir_args *ap)
1111
+vboxfs_rmdir(struct vop_rmdir_args *ap)
1075
 {
1112
 {
Lines 1088-1109 Link Here
1088
+	np = VP_TO_VBOXFS_NODE(vp);
1125
+	np = VP_TO_VBOXFS_NODE(vp);
1089
+	dir = VP_TO_VBOXFS_NODE(vp);
1126
+	dir = VP_TO_VBOXFS_NODE(vp);
1090
+
1127
+
1091
+	/*
1092
+	 * If anything else is using this vnode, then fail the remove.
1093
+	 * Why?  Windows hosts can't sfprov_remove() a file that is open,
1094
+	 * so we have to sfprov_close() it first.
1095
+	 * There is no errno for this - since it's not a problem on UNIX,
1096
+	 * but ETXTBSY is the closest.
1097
+	 */
1098
+	if (np->sf_file != NULL) {
1099
+		if (vp->v_usecount > 1) {
1100
+			error = ETXTBSY;
1101
+			goto out;
1102
+		}
1103
+		sfprov_close(np->sf_file);
1104
+		np->sf_file = NULL;
1105
+	}
1106
+
1107
+	error = sfprov_rmdir(np->vboxfsmp->sf_handle, np->sf_path);
1128
+	error = sfprov_rmdir(np->vboxfsmp->sf_handle, np->sf_path);
1108
+
1129
+
1109
+#if 0
1130
+#if 0
Lines 1118-1124 Link Here
1118
+	return (error);
1139
+	return (error);
1119
 }
1140
 }
1120
 
1141
 
1121
-static int vboxvfs_reclaim(struct vop_reclaim_args *ap)
1142
-static int vboxvfs_putpages(struct vop_putpages_args *ap)
1122
+static int
1143
+static int
1123
+vboxfs_readdir(struct vop_readdir_args *ap)
1144
+vboxfs_readdir(struct vop_readdir_args *ap)
1124
 {
1145
 {
Lines 1243-1253 Link Here
1243
+	return (error);
1264
+	return (error);
1244
 }
1265
 }
1245
 
1266
 
1246
-static int vboxvfs_getpages(struct vop_getpages_args *ap)
1247
+static int
1267
+static int
1248
+vboxfs_readlink(struct vop_readlink_args *v)
1268
+vboxfs_readlink(struct vop_readlink_args *v)
1249
 {
1269
+{
1250
-    return 0;
1251
+	struct vnode *vp = v->a_vp;
1270
+	struct vnode *vp = v->a_vp;
1252
+	struct uio *uio = v->a_uio;
1271
+	struct uio *uio = v->a_uio;
1253
+
1272
+
Lines 1275-1287 Link Here
1275
+	if (tmpbuf)
1294
+	if (tmpbuf)
1276
+		contigfree(tmpbuf, MAXPATHLEN, M_DEVBUF);
1295
+		contigfree(tmpbuf, MAXPATHLEN, M_DEVBUF);
1277
+	return (error);
1296
+	return (error);
1278
 }
1297
+}
1279
 
1298
+
1280
-static int vboxvfs_putpages(struct vop_putpages_args *ap)
1281
+static int
1299
+static int
1282
+vboxfs_fsync(struct vop_fsync_args *ap)
1300
+vboxfs_fsync(struct vop_fsync_args *ap)
1283
 {
1301
+{
1284
-    return 0;
1285
+	struct vnode *vp;
1302
+	struct vnode *vp;
1286
+	struct vboxfs_node *np;
1303
+	struct vboxfs_node *np;
1287
+	int ret;
1304
+	int ret;
Lines 1292-1299 Link Here
1292
+		return (0);
1309
+		return (0);
1293
+	ret = sfprov_fsync(np->sf_file);
1310
+	ret = sfprov_fsync(np->sf_file);
1294
+	return (ret);
1311
+	return (ret);
1295
 }
1312
+}
1296
 
1313
+
1297
+static int
1314
+static int
1298
+vboxfs_print(struct vop_print_args *ap)
1315
+vboxfs_print(struct vop_print_args *ap)
1299
+{
1316
+{
Lines 1349-1365 Link Here
1349
+ * Lookup an entry in a directory and create a new vnode if found.
1366
+ * Lookup an entry in a directory and create a new vnode if found.
1350
+ */
1367
+ */
1351
+static int
1368
+static int
1352
+vboxfs_lookup(struct vop_cachedlookup_args /* {
1369
+vboxfs_lookup1(struct vnode *dvp, struct vnode **vpp,
1353
+		struct vnodeop_desc *a_desc;
1370
+    struct componentname *cnp)
1354
+		struct vnode *a_dvp;
1355
+		struct vnode **a_vpp;
1356
+		struct componentname *a_cnp;
1357
+	} */ *ap)
1358
+{
1371
+{
1359
+	struct 	componentname *cnp = ap->a_cnp;
1360
+	struct 	vnode *dvp = ap->a_dvp;		/* the directory vnode */
1361
+	char	*nameptr = cnp->cn_nameptr;	/* the name of the file or directory */
1372
+	char	*nameptr = cnp->cn_nameptr;	/* the name of the file or directory */
1362
+	struct	vnode **vpp = ap->a_vpp;	/* the vnode we found or NULL */
1363
+	struct  vnode *tdp = NULL;
1373
+	struct  vnode *tdp = NULL;
1364
+	struct 	vboxfs_node *node = VP_TO_VBOXFS_NODE(dvp);
1374
+	struct 	vboxfs_node *node = VP_TO_VBOXFS_NODE(dvp);
1365
+	struct 	vboxfs_mnt *vboxfsmp = node->vboxfsmp;
1375
+	struct 	vboxfs_mnt *vboxfsmp = node->vboxfsmp;
Lines 1372-1377 Link Here
1372
+	int 	lkflags = cnp->cn_lkflags;
1382
+	int 	lkflags = cnp->cn_lkflags;
1373
+	char	*fullpath = NULL;
1383
+	char	*fullpath = NULL;
1374
+
1384
+
1385
+	*vpp = NULLVP;
1375
+	error = ENOENT;
1386
+	error = ENOENT;
1376
+	if (cnp->cn_flags & ISDOTDOT) {
1387
+	if (cnp->cn_flags & ISDOTDOT) {
1377
+		error = vn_vget_ino_gen(dvp, vboxfs_vn_get_ino_alloc,
1388
+		error = vn_vget_ino_gen(dvp, vboxfs_vn_get_ino_alloc,
Lines 1444-1449 Link Here
1444
+}
1455
+}
1445
+
1456
+
1446
+static int
1457
+static int
1458
+vboxfs_cachedlookup(struct vop_cachedlookup_args *ap)
1459
+{
1460
+	return (vboxfs_lookup1(ap->a_dvp, ap->a_vpp, ap->a_cnp));
1461
+}
1462
+
1463
+static int
1464
+vboxfs_lookup(struct vop_lookup_args *ap)
1465
+{
1466
+	struct vnode *dvp = ap->a_dvp;
1467
+	struct componentname *cnp = ap->a_cnp;
1468
+	struct vboxfs_node *np = VP_TO_VBOXFS_NODE(dvp);
1469
+	struct timespec mtime;
1470
+	int flags = cnp->cn_flags;
1471
+	int error;
1472
+
1473
+	if (dvp->v_type != VDIR)
1474
+		return (ENOTDIR);
1475
+
1476
+	if ((flags & ISLASTCN) && (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
1477
+	    (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
1478
+		return (EROFS);
1479
+
1480
+	error = vn_dir_check_exec(dvp, cnp);
1481
+	if (error != 0)
1482
+		return (error);
1483
+
1484
+	/* Check if the directory is unmodified on the host. */
1485
+	mtime = np->sf_stat.sf_mtime;
1486
+	error = vsfnode_update_stat_cache(np);
1487
+	if (error == 0) {
1488
+		if (mtime.tv_sec == np->sf_stat.sf_mtime.tv_sec &&
1489
+		    mtime.tv_nsec == np->sf_stat.sf_mtime.tv_nsec)
1490
+			return (vfs_cache_lookup(ap));
1491
+	}
1492
+
1493
+	cache_purge(dvp);
1494
+
1495
+	return (vboxfs_lookup1(ap->a_dvp, ap->a_vpp, ap->a_cnp));
1496
+}
1497
+
1498
+static int
1447
+vboxfs_inactive(struct vop_inactive_args *ap)
1499
+vboxfs_inactive(struct vop_inactive_args *ap)
1448
+{
1500
+{
1449
+   	return (0);
1501
+   	return (0);
1450
- 

Return to bug 245865