- Fix build error with gcc4.2 [1]

- Fix panic on Head [2]

PR:		112387 / 112989
Submitted by:	Artem Naluzhny<tut@nhamon.com.ua> [1]
                Anish Mistry <amistry@am-productions.biz> (maintainer) [2]
This commit is contained in:
Martin Wilke 2007-05-29 15:51:32 +00:00
parent cab028aec8
commit c33a4eedb3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=192307
3 changed files with 226 additions and 43 deletions

View file

@ -7,7 +7,7 @@
PORTNAME= fusefs
PORTVERSION= 0.3.0
PORTREVISION= 4
PORTREVISION= 5
CATEGORIES= sysutils
MASTER_SITES= http://fuse4bsd.creo.hu/downloads/ \
http://am-productions.biz/docs/

View file

@ -1,5 +1,5 @@
--- fuse_module/fuse.c.orig Wed Sep 27 15:49:47 2006
+++ fuse_module/fuse.c Wed Sep 27 15:52:02 2006
--- fuse_module/fuse.c.orig Sat Feb 11 00:31:53 2006
+++ fuse_module/fuse.c Fri May 25 14:54:26 2007
@@ -75,7 +75,7 @@
};
@ -141,7 +141,53 @@
static struct vop_vector fuse_germ_vnops;
#endif
@@ -2092,7 +2092,7 @@
@@ -2070,29 +2070,42 @@
M_WAITOK | M_ZERO);
err = getnewvnode("fuse", mp, &fuse_vnops, &rvp);
+ if (! err) {
+ err = vn_lock(rvp, LK_EXCLUSIVE | LK_RETRY, td);
+#if NEW_VNODES_ADJUSTED_MANUALLY
+ if (err)
+ printf("fuse4bsd: leaking vnode %p\n", rvp);
+#endif
+ }
+
+ if (! err) {
+ /*
+ * FUSE_ROOT_ID as an inode number will be resolved directly.
+ * without resorting to the vfs hashing mechanism, thus it also
+ * can be inserted directly to the v_hash slot.
+ */
+ rvp->v_hash = FUSE_ROOT_ID;
+ fmnt->rvp = rvp;
+ fuse_vnode_init(rvp, fvdat, FUSE_ROOT_ID, VNON);
+ rvp->v_vflag |= VV_ROOT;
+#if NEW_VNODES_ADJUSTED_MANUALLY
+ err = insmntque(rvp, mp);
+#endif
+ }
if (err) {
fdata_kick_set(data);
sx_xunlock(slock);
FREE(fvdat, M_FUSEFS);
goto out;
- }
-
- /*
- * FUSE_ROOT_ID as an inode number will be resolved directly.
- * without resorting to the vfs hashing mechanism, thus it also
- * can be inserted directly to the v_hash slot.
- */
- rvp->v_hash = FUSE_ROOT_ID;
- fmnt->rvp = rvp;
- fuse_vnode_init(rvp, fvdat, FUSE_ROOT_ID, VNON);
- rvp->v_vflag |= VV_ROOT;
+ } else
+ VOP_UNLOCK(rvp, 0, td);
rootdone:
if (! (fmnt->mntopts & FUSEFS_SECONDARY)) {
data->mp = mp;
@ -150,7 +196,7 @@
fmnt->mntopts &= ~FUSEFS_UNPRIVPROCDBG;
fmnt->mntopts |= get_unprivileged_proc_debug(td) ? FUSEFS_UNPRIVPROCDBG : 0;
#endif
@@ -2380,7 +2380,7 @@
@@ -2380,7 +2393,7 @@
return (0);
}
@ -159,7 +205,47 @@
/*
* Vnode comparison function with which the given vnode always
* gets inserted, but got marked invalid upon a clash. Caller
@@ -2654,7 +2654,7 @@
@@ -2405,11 +2418,11 @@
fuse_vget_i(struct mount *mp, struct thread *td, uint64_t nodeid,
enum vtype vtyp, struct vnode **vpp, int wantnew)
{
+#define myflags LK_EXCLUSIVE | LK_RETRY
int err = 0;
struct fuse_mnt_data *fmnt;
struct fuse_vnode_data *fvdat;
struct vnode *vp2;
- int myflags = LK_EXCLUSIVE;
DEBUG2G("mp %p: %s\n", mp, mp->mnt_stat.f_mntfromname);
DEBUG("been asked for vno #%llu\n", (unsigned long long)nodeid);
@@ -2470,6 +2483,18 @@
return (err);
}
+#if NEW_VNODES_ADJUSTED_MANUALLY
+ err = vn_lock(*vpp, myflags, td);
+ if (err)
+ printf("fuse4bsd: leaking vnode %p\n", *vpp);
+ else
+ err = insmntque(*vpp, mp);
+ if (err) {
+ free(fvdat, M_FUSEFS);
+ return (err);
+ }
+#endif
+
/*
* There is no harm in fully initializing the vnode before trying
* at insertion, because vnodes are gc-d anyway. For the same reason,
@@ -2504,6 +2529,7 @@
vn_printf(*vpp, " * ");
#endif
return (err);
+#undef myflags
}
@@ -2654,7 +2680,7 @@
fuse_filehandle_gc(vp, td, NULL);
@ -168,7 +254,7 @@
/*
* Dropping vnodes when they are not in use would mean that
* the respective inode must be freed on the daemon's side
@@ -2751,7 +2751,7 @@
@@ -2751,7 +2777,7 @@
int denied;
if ((denied = cr_candebug(
@ -177,7 +263,7 @@
get_unprivileged_proc_debug(td),
#else
fmnt->mntopts & FUSEFS_UNPRIVPROCDBG,
@@ -2948,7 +2948,7 @@
@@ -2948,7 +2974,7 @@
} else {
struct sx *devlock = fdi.slock;
@ -186,7 +272,7 @@
struct fuse_access_in *fai;
if (! (facp->facc_flags & FACCESS_DO_ACCESS))
@@ -3056,7 +3056,7 @@
@@ -3056,7 +3082,7 @@
bzero(&facp, sizeof(facp));
if (
@ -195,7 +281,7 @@
1
#else
dvp->v_vflag & VV_ROOT
@@ -3281,8 +3281,12 @@
@@ -3281,8 +3307,12 @@
DEBUG("we peacefully found that file\n");
if (flags & ISDOTDOT) {
@ -209,7 +295,7 @@
*vpp = pdp;
} else if (nid == VTOI(dvp)) {
VREF(dvp); /* We want ourself, ie "." */
@@ -3347,7 +3351,7 @@
@@ -3347,7 +3377,7 @@
if (islastcn && flags & ISOPEN)
((struct fuse_vnode_data *)(*vpp)->v_data)->flags |= FVP_ACCESS_NOOP;
@ -218,7 +304,7 @@
if (! islastcn) {
/* We have the attributes of the next item
* *now*, and it's a fact, and we do not have
@@ -3486,7 +3490,7 @@
@@ -3486,7 +3516,7 @@
return (0);
}
@ -227,7 +313,28 @@
static __inline int
create_filehandle(struct vnode *vp, struct thread *td, struct ucred *cred,
int mode, struct fuse_dispatcher *fdip)
@@ -3643,7 +3647,7 @@
@@ -3567,7 +3597,20 @@
bzero(fvdat, sizeof(*fvdat));
fuse_vnode_init(vp, fvdat, feo->nodeid, VREG);
vp->v_op = &fuse_vnops;
+#if NEW_VNODES_ADJUSTED_MANUALLY
+ {
+ struct mount *mp = vp->v_mount;
+
+ vp->v_mount = NULL;
+ err = insmntque(vp, mp);
+ if (err) {
+ free(fvdat, M_FUSEFS);
+ return (err);
+ }
+ }
+#else
VOP_UNLOCK(vp, 0, td);
+#endif
/*
* We can't let the vnode being vput() here, the caller wants
* that do by herself.
@@ -3643,7 +3686,7 @@
* the vnode... if the vnode is a germ, it will be tried to be initialized
* via a dedicated method, but from that on we go on as usual.)
*/
@ -236,7 +343,7 @@
if (vp->v_op == &fuse_germ_vnops) {
KASSERT(gefhp, ("create_filehandle called without get_filehandle_param"));
gone_create = 1;
@@ -3709,7 +3713,7 @@
@@ -3709,7 +3752,7 @@
if ((err = fdisp_wait_answ(&fdi)))
goto out;
@ -245,7 +352,7 @@
setup_filehandle:
#endif
foo = fdi.answ;
@@ -4184,7 +4188,7 @@
@@ -4184,7 +4227,7 @@
#define BSD_FUSE_PAGENO_BOUND MIN(FUSE_MAX_PAGES_PER_REQ, MAXBSIZE / PAGE_SIZE)
bcount = MIN(MAXBSIZE, biosize * BSD_FUSE_PAGENO_BOUND);
@ -254,16 +361,33 @@
if (vp->v_type != VDIR) {
/*
* for directories we can't predict the size, in fact
@@ -4493,7 +4497,7 @@
@@ -4215,11 +4258,9 @@
#if _DEBUG
prettyprint(bp->b_data, 48);
printf("\n");
-#if ZERO_PAD_INCOMPLETE_BUFS
prettyprint(bp->b_data + PAGE_SIZE, 48);
printf("\n");
#endif
-#endif
if (err) {
brelse(bp);
return (err);
@@ -4493,13 +4534,6 @@
break;
}
-#if ZERO_PAD_INCOMPLETE_BUFS
+#ifdef ZERO_PAD_INCOMPLETE_BUFS
if (isbzero(buf), FUSE_NAME_OFFSET) {
err = -1;
break;
@@ -4658,7 +4662,7 @@
- if (isbzero(buf), FUSE_NAME_OFFSET) {
- err = -1;
- break;
- }
-#endif
-
/* Sanity checks */
if (!fudge->namelen || fudge->namelen > MAXNAMLEN) {
@@ -4658,7 +4692,7 @@
struct vnode *dvp = ap->a_dvp;
struct vnode **vpp = ap->a_vpp;
struct vattr *vap = ap->a_vap;
@ -272,7 +396,31 @@
struct fuse_dispatcher fdi;
struct fuse_vnode_data *fvdat;
int err;
@@ -4949,7 +4953,7 @@
@@ -4683,8 +4717,12 @@
if ((err = getnewvnode("fuse", dvp->v_mount, &fuse_vnops, vpp)))
return (err);
- if ((err = vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curthread)))
+ if ((err = vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curthread))) {
+#if NEW_VNODES_ADJUSTED_MANUALLY
+ printf("fuse4bsd: leaking vnode %p\n", *vpp);
+#endif
return (err);
+ }
MALLOC(fvdat, struct fuse_vnode_data *, sizeof(*fvdat), M_FUSEFS,
M_WAITOK | M_ZERO);
@@ -4704,6 +4742,9 @@
*/
(*vpp)->v_op = &fuse_germ_vnops;
(*vpp)->v_data = fvdat;
+#if NEW_VNODES_ADJUSTED_MANUALLY
+ (*vpp)->v_mount = dvp->v_mount;
+#endif
return (0);
@@ -4949,7 +4990,7 @@
if (err)
goto out;
@ -281,7 +429,7 @@
if (doingdirectory && fdvp != tdvp) {
/*
* Check for pathname conflict.
@@ -5396,7 +5400,6 @@
@@ -5396,7 +5437,6 @@
struct vnode *vp = fioda->vp;
struct uio *uio = fioda->uio;
struct ucred *cred = fioda->cred;
@ -289,7 +437,7 @@
int biosize;
@@ -5506,7 +5509,7 @@
@@ -5506,7 +5546,7 @@
if ((bp->b_flags & B_CACHE) == 0) {
bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0);
@ -298,16 +446,34 @@
if ((err = bp->b_error)) {
brelse(bp);
break;
@@ -5741,7 +5744,7 @@
@@ -5741,23 +5781,16 @@
chunksize, (long long unsigned)fri->offset, respsize);
if (respsize < chunksize) {
-#if ZERO_PAD_INCOMPLETE_BUFS
+#ifdef ZERO_PAD_INCOMPLETE_BUFS
/*
* "if we don't get enough data, just fill the
* rest with zeros."
@@ -5888,7 +5891,7 @@
- * "if we don't get enough data, just fill the
- * rest with zeros."
- * in nfs context this means a hole in the
- * file, I don't know what to do with this
- * here... [we just get a buch of zeroes
- * instead of EOF, baaad]
+ * if we don't get enough data, just fill the
+ * rest with zeros.
*/
DEBUG("zeroing tail of %ld bytes\n",
bp->b_resid);
bzero((char *)bp->b_data + bp->b_bcount - bp->b_resid,
bp->b_resid);
- bp->b_resid = 0;
-#else
+
break;
-#endif
}
ticket_refresh(fdi.tick);
DEBUG("bp->b_data %p\n", bp->b_data);
@@ -5888,7 +5921,7 @@
"vp=%p, rc=%d", bp, vp, rc));
}
@ -316,7 +482,7 @@
static int
fuse_germ_access(struct vop_access_args *ap)
{
@@ -5908,7 +5911,7 @@
@@ -5908,7 +5941,7 @@
/* Modeled after tunclone() of net/if_tun.c
*/
@ -325,7 +491,7 @@
static void
fusedev_clone(void *arg, char *name, int namelen, struct cdev **dev)
#else
@@ -6019,7 +6022,7 @@
@@ -6019,7 +6052,7 @@
fuse_fileops.fo_close = fuse_close_f;
fuse_fileops.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE;
@ -334,3 +500,12 @@
memcpy(&fuse_germ_vnops, &dead_vnodeops, sizeof(struct vop_vector));
fuse_germ_vnops.vop_access = fuse_germ_access;
fuse_germ_vnops.vop_open = fuse_open;
@@ -6089,7 +6092,7 @@
/* Registering the module */
-static struct vfsconf fuse_vfsconf = {
+struct vfsconf fuse_vfsconf = {
.vfc_version = VFS_VERSION,
.vfc_name = "fusefs",
.vfc_vfsops = &fuse_vfsops,

View file

@ -1,15 +1,23 @@
--- fuse_module/fuse.h.orig Fri Feb 10 17:31:53 2006
+++ fuse_module/fuse.h Sun Jul 16 14:43:20 2006
@@ -8,7 +8,7 @@
--- fuse_module/fuse.h.orig Thu May 3 13:26:25 2007
+++ fuse_module/fuse.h Thu May 3 13:26:03 2007
@@ -8,7 +8,15 @@
#ifndef USE_OLD_CLONEHANDLER_API
#if __FreeBSD_version < 600034 || ( __FreeBSD_version >= 700000 && __FreeBSD_version < 700002 )
-#define USE_OLD_CLONEHANDLER_API 1
+#define USE_OLD_CLONEHANDLER_API
+#endif
+#endif
+
+#ifndef NEW_VNODES_ADJUSTED_MANUALLY
+#if __FreeBSD_version >= 700034
+#define NEW_VNODES_ADJUSTED_MANUALLY 1
+#else
+#define NEW_VNODES_ADJUSTED_MANUALLY 0
#endif
#endif
@@ -19,10 +19,10 @@
@@ -19,10 +27,10 @@
*/
#if FUSE_KERNELABI_GEQ(7, 3)
#ifndef FUSE_HAS_ACCESS
@ -22,7 +30,7 @@
#endif
#endif
@@ -75,7 +75,7 @@
@@ -75,7 +83,7 @@
size_t len; /* To keep track of size of the data pushed into base, =< len, of course */
};
@ -31,7 +39,7 @@
#ifndef FUSE_MAX_STORED_FREE_TICKETS
#define FUSE_MAX_STORED_FREE_TICKETS 0
#endif
@@ -251,7 +251,7 @@
@@ -251,7 +259,7 @@
int flags;
LIST_HEAD(, fuse_filehandle) fh_head;
int fh_counter;
@ -40,7 +48,7 @@
struct componentname *germcnp;
#endif
};
@@ -260,6 +260,9 @@
@@ -260,6 +268,9 @@
/* Debug related stuff */
@ -50,7 +58,7 @@
#if DEBUGTOLOG
#define dprintf(args ...) log(LOG_DEBUG, args)
#else
@@ -267,6 +270,9 @@
@@ -267,6 +278,9 @@
#endif
#define DEBLABEL "[fuse-debug] "
@ -60,7 +68,7 @@
#if _DEBUG
#ifndef _DEBUG2G
#define _DEBUG2G 1
@@ -280,6 +286,9 @@
@@ -280,6 +294,9 @@
#define DEBUG(args ...)
#endif
@ -70,7 +78,7 @@
#if _DEBUG2G
#ifndef _DEBUG3G
#define _DEBUG3G 1
@@ -290,6 +299,9 @@
@@ -290,6 +307,9 @@
#define DEBUG2G(args ...)
#endif
@ -80,7 +88,7 @@
#if _DEBUG3G
#define DEBUG3G(args, ...) \
printf(DEBLABEL "%s:%d: " args, __func__, __LINE__, ## __VA_ARGS__)
@@ -297,13 +309,19 @@
@@ -297,13 +317,19 @@
#define DEBUG3G(args ...)
#endif
@ -101,7 +109,7 @@
#define fuprintf(args...) \
uprintf("[kern] " args)
#else
@@ -319,7 +337,7 @@
@@ -319,7 +345,7 @@
void fprettyprint(struct fuse_iov *fiov, size_t dlen);
#endif