Module Name: src Committed By: pooka Date: Fri Oct 2 09:32:01 UTC 2009
Modified Files: src/lib/libukfs: ukfs.c ukfs.h Log Message: * allow callers to store a private data pointer behind the ukfs handle * release reference on root vnode before unmounting (and reaquire the root vnode if unmount fails) * return correct error value if unmount fails To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libukfs/ukfs.c cvs rdiff -u -r1.9 -r1.10 src/lib/libukfs/ukfs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libukfs/ukfs.c diff -u src/lib/libukfs/ukfs.c:1.36 src/lib/libukfs/ukfs.c:1.37 --- src/lib/libukfs/ukfs.c:1.36 Tue Sep 29 11:17:00 2009 +++ src/lib/libukfs/ukfs.c Fri Oct 2 09:32:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ukfs.c,v 1.36 2009/09/29 11:17:00 pooka Exp $ */ +/* $NetBSD: ukfs.c,v 1.37 2009/10/02 09:32:01 pooka Exp $ */ /* * Copyright (c) 2007, 2008 Antti Kantee. All Rights Reserved. @@ -68,6 +68,7 @@ struct ukfs { struct mount *ukfs_mp; struct vnode *ukfs_rvp; + void *ukfs_specific; pthread_spinlock_t ukfs_spin; pid_t ukfs_nextpid; @@ -98,6 +99,20 @@ return rvp; } +void +ukfs_setspecific(struct ukfs *ukfs, void *priv) +{ + + ukfs->ukfs_specific = priv; +} + +void * +ukfs_getspecific(struct ukfs *ukfs) +{ + + return ukfs->ukfs_specific; +} + #ifdef DONT_WANT_PTHREAD_LINKAGE #define pthread_spin_lock(a) #define pthread_spin_unlock(a) @@ -302,20 +317,25 @@ { if ((flags & UKFS_RELFLAG_NOUNMOUNT) == 0) { - int rv, mntflag; + int rv, mntflag, error; ukfs_chdir(fs, "/"); mntflag = 0; if (flags & UKFS_RELFLAG_FORCE) mntflag = MNT_FORCE; rump_setup_curlwp(nextpid(fs), 1, 1); + rump_vp_rele(fs->ukfs_rvp); + fs->ukfs_rvp = NULL; rv = rump_sys_unmount(fs->ukfs_mountpath, mntflag); - rump_clear_curlwp(); - if (rv) { + if (rv == -1) { + error = errno; + rump_vfs_root(fs->ukfs_mp, &fs->ukfs_rvp, 0); + rump_clear_curlwp(); ukfs_chdir(fs, fs->ukfs_mountpath); - errno = rv; + errno = error; return -1; } + rump_clear_curlwp(); } if (fs->ukfs_devpath) { Index: src/lib/libukfs/ukfs.h diff -u src/lib/libukfs/ukfs.h:1.9 src/lib/libukfs/ukfs.h:1.10 --- src/lib/libukfs/ukfs.h:1.9 Wed Jul 22 20:46:34 2009 +++ src/lib/libukfs/ukfs.h Fri Oct 2 09:32:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ukfs.h,v 1.9 2009/07/22 20:46:34 pooka Exp $ */ +/* $NetBSD: ukfs.h,v 1.10 2009/10/02 09:32:01 pooka Exp $ */ /* * Copyright (c) 2007, 2008 Antti Kantee. All Rights Reserved. @@ -108,6 +108,8 @@ struct mount *ukfs_getmp(struct ukfs *); struct vnode *ukfs_getrvp(struct ukfs *); +void ukfs_setspecific(struct ukfs *, void *); +void * ukfs_getspecific(struct ukfs *); /* dynamic loading of library modules */ int ukfs_modload(const char *);