CVS commit: src/lib/libukfs

2018-03-12 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Mar 12 11:56:34 UTC 2018

Modified Files:
src/lib/libukfs: ukfs.3

Log Message:
Remove exgtraneous comma


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libukfs/ukfs.3

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.3
diff -u src/lib/libukfs/ukfs.3:1.15 src/lib/libukfs/ukfs.3:1.16
--- src/lib/libukfs/ukfs.3:1.15	Thu Feb  8 09:05:17 2018
+++ src/lib/libukfs/ukfs.3	Mon Mar 12 11:56:34 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: ukfs.3,v 1.15 2018/02/08 09:05:17 dholland Exp $
+.\" $NetBSD: ukfs.3,v 1.16 2018/03/12 11:56:34 pgoyette Exp $
 .\"
 .\" Copyright (c) 2008 Antti Kantee.  All rights reserved.
 .\"
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 13, 2014
+.Dd March 12, 2018
 .Dt UKFS 3
 .Os
 .Sh NAME
@@ -57,7 +57,7 @@ If a lower level interface it desired,
 .Xr rump 3
 kernels should be used directly.
 However, much like system calls, the interfaces of
-.Nm ,
+.Nm
 are self-contained and require no tracking and release of resources.
 The only exception is the file system handle
 .Ft struct ukfs



CVS commit: src/lib/libukfs

2014-02-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Feb 14 01:11:04 UTC 2014

Modified Files:
src/lib/libukfs: ukfs.3

Log Message:
some minor updates and reality-checks


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libukfs/ukfs.3

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.3
diff -u src/lib/libukfs/ukfs.3:1.12 src/lib/libukfs/ukfs.3:1.13
--- src/lib/libukfs/ukfs.3:1.12	Sat Jul 20 21:39:57 2013
+++ src/lib/libukfs/ukfs.3	Fri Feb 14 01:11:04 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: ukfs.3,v 1.12 2013/07/20 21:39:57 wiz Exp $
+.\ $NetBSD: ukfs.3,v 1.13 2014/02/14 01:11:04 pooka Exp $
 .\
 .\ Copyright (c) 2008 Antti Kantee.  All rights reserved.
 .\
@@ -23,7 +23,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd November 22, 2009
+.Dd February 13, 2014
 .Dt UKFS 3
 .Os
 .Sh NAME
@@ -44,17 +44,17 @@ requires no special kernel support apart
 As
 .Nm
 is built upon
-.Xr rump 3 ,
-all kernel file systems which are supported by rump are available.
-It allows to write utilities for accessing file systems without having
-to duplicate file system internals knowledge already present in kernel
-file system drivers.
+.Xr rump 3
+kernels, all kernel file systems which are supported by rump kernels
+are available.  It allows to write utilities for accessing file systems
+without having to duplicate file system internals knowledge already
+present in kernel file system drivers.
 .Pp
 .Nm
 provides a high-level pathname based interface for accessing file systems.
 If a lower level interface it desired,
 .Xr rump 3
-should be used directly.
+kernels should be used directly.
 However, much like system calls, the interfaces of
 .Nm ,
 are self-contained and require no tracking and release of resources.
@@ -91,7 +91,7 @@ is used at runtime to dynamically load a
 file system module.
 For this to succeed, the
 .Xr rump 3
-library and the module targetted must be compiled with compatible kernel
+kernel and the module targetted must be compiled with compatible kernel
 versions and the application must be dynamically linked.
 Additionally, since this routine does not handle dependencies, all the
 dependencies of the library must be loaded beforehand.
@@ -101,7 +101,7 @@ for success.
 .Fn ukfs_modload_dir
 loads all
 .Xr rump 3
-file system modules in directory
+kernel file system components in directory
 .Fa dirname .
 It looks for libraries which begin with
 .Pa librumpfs_
@@ -316,13 +316,5 @@ first appeared in
 .An Antti Kantee Aq Mt po...@cs.hut.fi
 .Sh NOTES
 .Nm
-should be considered experimental technology and may change without warning.
-.Sh BUGS
-On Linux, dynamically linked binaries can include support for only
-one file system due to restrictions with the dynamic linker.
-If more are desired, they must be loaded at runtime using
-.Fn ukfs_modload .
-Even though
-.Nx
-does not have this restriction, portable programs should load all
-file system drivers dynamically.
+was an early attempt at an interface for kernel file systems
+running in userspace.



CVS commit: src/lib/libukfs

2014-02-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Feb 14 07:27:37 UTC 2014

Modified Files:
src/lib/libukfs: ukfs.3

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libukfs/ukfs.3

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.3
diff -u src/lib/libukfs/ukfs.3:1.13 src/lib/libukfs/ukfs.3:1.14
--- src/lib/libukfs/ukfs.3:1.13	Fri Feb 14 01:11:04 2014
+++ src/lib/libukfs/ukfs.3	Fri Feb 14 07:27:37 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: ukfs.3,v 1.13 2014/02/14 01:11:04 pooka Exp $
+.\ $NetBSD: ukfs.3,v 1.14 2014/02/14 07:27:37 wiz Exp $
 .\
 .\ Copyright (c) 2008 Antti Kantee.  All rights reserved.
 .\
@@ -46,7 +46,8 @@ As
 is built upon
 .Xr rump 3
 kernels, all kernel file systems which are supported by rump kernels
-are available.  It allows to write utilities for accessing file systems
+are available.
+It allows to write utilities for accessing file systems
 without having to duplicate file system internals knowledge already
 present in kernel file system drivers.
 .Pp



CVS commit: src/lib/libukfs

2012-07-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jul 19 06:33:03 UTC 2012

Modified Files:
src/lib/libukfs: ukfs.h

Log Message:
Always initialize part to avoid triggering uninitialized variable
warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.h
diff -u src/lib/libukfs/ukfs.h:1.13 src/lib/libukfs/ukfs.h:1.14
--- src/lib/libukfs/ukfs.h:1.13	Thu Dec  3 14:23:49 2009
+++ src/lib/libukfs/ukfs.h	Thu Jul 19 06:33:03 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.h,v 1.13 2009/12/03 14:23:49 pooka Exp $	*/
+/*	$NetBSD: ukfs.h,v 1.14 2012/07/19 06:33:03 joerg Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -130,8 +130,9 @@ extern struct ukfs_part *ukfs_part_na;
 
 #define UKFS_DEVICE_ARGVPROBE(part)	\
 do {	\
-	if (argc = 3)			\
-		if (ukfs_part_probe(argv[argc-2], part) == -1)	\
+	if (argc  3)			\
+		*part = NULL;		\
+	else if (ukfs_part_probe(argv[argc-2], part) == -1)		\
 			err(1, ukfs_part_probe);			\
 } while (/*CONSTCOND*/0)
 



CVS commit: src/lib/libukfs

2012-02-10 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Fri Feb 10 15:21:53 UTC 2012

Modified Files:
src/lib/libukfs: ukfs.3

Log Message:
Add missing Fa macro argument.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libukfs/ukfs.3

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.3
diff -u src/lib/libukfs/ukfs.3:1.10 src/lib/libukfs/ukfs.3:1.11
--- src/lib/libukfs/ukfs.3:1.10	Sun Nov 22 18:14:49 2009
+++ src/lib/libukfs/ukfs.3	Fri Feb 10 15:21:53 2012
@@ -1,4 +1,4 @@
-.\ $NetBSD: ukfs.3,v 1.10 2009/11/22 18:14:49 pooka Exp $
+.\ $NetBSD: ukfs.3,v 1.11 2012/02/10 15:21:53 njoly Exp $
 .\
 .\ Copyright (c) 2008 Antti Kantee.  All rights reserved.
 .\
@@ -292,7 +292,7 @@ in the sense that it affects the interpr
 If succesful, all relative pathnames will be resolved starting from the
 current directory.
 Currently the call affects all accesses to that particular
-.Fa ,
+.Fa ukfs ,
 but it might be later changed to be thread private.
 .Sh UTILITIES
 .Bl -ohang



CVS commit: src/lib/libukfs

2011-02-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Feb 22 15:42:15 UTC 2011

Modified Files:
src/lib/libukfs: ukfs.c ukfs_disklabel.c ukfs_int_disklabel.h

Log Message:
Add support for a byteswapped disklabel so that I can mount
NetBSD/sparc anita images on my i386.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/lib/libukfs/ukfs.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libukfs/ukfs_disklabel.c \
src/lib/libukfs/ukfs_int_disklabel.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.56 src/lib/libukfs/ukfs.c:1.57
--- src/lib/libukfs/ukfs.c:1.56	Sun Jan  2 13:01:45 2011
+++ src/lib/libukfs/ukfs.c	Tue Feb 22 15:42:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.56 2011/01/02 13:01:45 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.57 2011/02/22 15:42:15 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -246,9 +246,11 @@
 		*(MAGICADJ_DISKLABEL(p,0))  'a' + UKFS_MAXPARTITIONS) {
 			struct ukfs__disklabel dl;
 			struct ukfs__partition *pp;
+			int imswapped;
 			char buf[65536];
 			char labelchar = *(MAGICADJ_DISKLABEL(p,0));
 			int partition = labelchar - 'a';
+			uint32_t poffset, psize;
 
 			*p = '\0';
 			devfd = open(devpath, O_RDONLY);
@@ -263,7 +265,8 @@
 goto out;
 			}
 
-			if (ukfs__disklabel_scan(dl, buf, sizeof(buf)) != 0) {
+			if (ukfs__disklabel_scan(dl, imswapped,
+			buf, sizeof(buf)) != 0) {
 error = ENOENT;
 goto out;
 			}
@@ -276,8 +279,15 @@
 			pp = dl.d_partitions[partition];
 			part-part_type = UKFS_PART_DISKLABEL;
 			part-part_labelchar = labelchar;
-			part-part_devoff = pp-p_offset  DEV_BSHIFT;
-			part-part_devsize = pp-p_size  DEV_BSHIFT;
+			if (imswapped) {
+poffset = bswap32(pp-p_offset);
+psize = bswap32(pp-p_size);
+			} else {
+poffset = pp-p_offset;
+psize = pp-p_size;
+			}
+			part-part_devoff = poffset  DEV_BSHIFT;
+			part-part_devsize = psize  DEV_BSHIFT;
 		} else {
 			error = EINVAL;
 		}

Index: src/lib/libukfs/ukfs_disklabel.c
diff -u src/lib/libukfs/ukfs_disklabel.c:1.2 src/lib/libukfs/ukfs_disklabel.c:1.3
--- src/lib/libukfs/ukfs_disklabel.c:1.2	Thu Dec  3 14:23:49 2009
+++ src/lib/libukfs/ukfs_disklabel.c	Tue Feb 22 15:42:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs_disklabel.c,v 1.2 2009/12/03 14:23:49 pooka Exp $	*/
+/*	$NetBSD: ukfs_disklabel.c,v 1.3 2011/02/22 15:42:15 pooka Exp $	*/
 
 /*
  * Local copies of libutil disklabel routines.  This uncouples libukfs
@@ -50,27 +50,42 @@
 #define SCAN_INCR	4
 
 int
-ukfs__disklabel_scan(struct ukfs__disklabel *lp, char *buf, size_t buflen)
+ukfs__disklabel_scan(struct ukfs__disklabel *lp, int *isswapped,
+	char *buf, size_t buflen)
 {
-	size_t	i;
+	size_t i;
+	int imswapped;
+	uint16_t npart;
 
 	/* scan for the correct magic numbers. */
 
 	for (i=0; i = buflen - sizeof(*lp); i += SCAN_INCR) {
 		memcpy(lp, buf + i, sizeof(*lp));
 		if (lp-d_magic == UKFS_DISKMAGIC 
-		lp-d_magic2 == UKFS_DISKMAGIC)
+		lp-d_magic2 == UKFS_DISKMAGIC) {
+			imswapped = 0;
 			goto sanity;
+		}
+		if (lp-d_magic == bswap32(UKFS_DISKMAGIC) 
+		lp-d_magic2 == bswap32(UKFS_DISKMAGIC)) {
+			imswapped = 1;
+			goto sanity;
+		}
 	}
 
 	return 1;
 
 sanity:
+	if (imswapped)
+		npart = bswap16(lp-d_npartitions);
+	else
+		npart = lp-d_npartitions;
 	/* we've found something, let's sanity check it */
-	if (lp-d_npartitions  UKFS_MAXPARTITIONS
-	|| ukfs__disklabel_dkcksum(lp))
+	if (npart  UKFS_MAXPARTITIONS
+	|| ukfs__disklabel_dkcksum(lp, imswapped))
 		return 1;
 
+	*isswapped = imswapped;
 	return 0;
 }
 
@@ -110,15 +125,26 @@
  */
 
 uint16_t
-ukfs__disklabel_dkcksum(struct ukfs__disklabel *lp)
+ukfs__disklabel_dkcksum(struct ukfs__disklabel *lp, int imswapped)
 {
 	uint16_t *start, *end;
 	uint16_t sum;
+	uint16_t npart;
+
+	if (imswapped)
+		npart = bswap16(lp-d_npartitions);
+	else
+		npart = lp-d_npartitions;
 
 	sum = 0;
 	start = (uint16_t *)(void *)lp;
-	end = (uint16_t *)(void *)lp-d_partitions[lp-d_npartitions];
-	while (start  end)
-		sum ^= *start++;
+	end = (uint16_t *)(void *)lp-d_partitions[npart];
+	while (start  end) {
+		if (imswapped)
+			sum ^= bswap16(*start);
+		else
+			sum ^= *start;
+		start++;
+	}
 	return (sum);
 }
Index: src/lib/libukfs/ukfs_int_disklabel.h
diff -u src/lib/libukfs/ukfs_int_disklabel.h:1.2 src/lib/libukfs/ukfs_int_disklabel.h:1.3
--- src/lib/libukfs/ukfs_int_disklabel.h:1.2	Thu Dec  3 14:23:49 2009
+++ src/lib/libukfs/ukfs_int_disklabel.h	Tue Feb 22 15:42:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs_int_disklabel.h,v 1.2 2009/12/03 14:23:49 pooka Exp $	*/
+/*	$NetBSD: ukfs_int_disklabel.h,v 1.3 2011/02/22 15:42:15 pooka Exp $	*/
 
 /*
  * Modified copy of disklabel.h so that ukfs doesn't have to depend
@@ -151,7 +151,8 @@
 	} d_partitions[UKFS_MAXPARTITIONS];	/* actually may be more */
 };
 
-uint16_t

CVS commit: src/lib/libukfs

2010-11-26 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Nov 26 11:10:53 UTC 2010

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
rumpuser should not be included outside of the rump kernel (and
rumpuser itself)


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/lib/libukfs/ukfs.c

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.54 src/lib/libukfs/ukfs.c:1.55
--- src/lib/libukfs/ukfs.c:1.54	Tue Sep  7 17:16:18 2010
+++ src/lib/libukfs/ukfs.c	Fri Nov 26 11:10:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.54 2010/09/07 17:16:18 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.55 2010/11/26 11:10:53 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -62,7 +62,6 @@
 
 #include rump/rump.h
 #include rump/rump_syscalls.h
-#include rump/rumpuser.h
 
 #include ukfs_int_disklabel.h
 



CVS commit: src/lib/libukfs

2009-12-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Dec 13 20:52:36 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
Refcount ukfs_part.  Otherwise it's not possible to call ukfs_mount()
several times with only one ukfs_part_probe().


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/lib/libukfs/ukfs.c

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.46 src/lib/libukfs/ukfs.c:1.47
--- src/lib/libukfs/ukfs.c:1.46	Sat Dec 12 00:46:04 2009
+++ src/lib/libukfs/ukfs.c	Sun Dec 13 20:52:36 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.46 2009/12/12 00:46:04 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.47 2009/12/13 20:52:36 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -164,6 +164,9 @@
 }
 
 struct ukfs_part {
+	pthread_spinlock_t part_lck;
+	int part_refcount;
+
 	int part_type;
 	char part_labelchar;
 	off_t part_devoff;
@@ -231,7 +234,14 @@
 		errno = ENOMEM;
 		return -1;
 	}
+	if (pthread_spin_init(part-part_lck, PTHREAD_PROCESS_PRIVATE) == -1) {
+		error = errno;
+		free(part);
+		errno = error;
+		return -1;
+	}
 	part-part_type = UKFS_PART_NONE;
+	part-part_refcount = 1;
 
 	/*
 	 * Check for magic in pathname:
@@ -338,7 +348,7 @@
 		part-part_devsize = val;
 		part-part_type = UKFS_PART_OFFSET;
 	} else {
-		free(part);
+		ukfs_part_release(part);
 		part = ukfs_part_none;
 	}
 
@@ -395,6 +405,9 @@
 {
 	struct flock flarg;
 
+	if (part == ukfs_part_na)
+		return;
+
 	memset(flarg, 0, sizeof(flarg));
 	flarg.l_type = F_UNLCK;
 	flarg.l_whence = SEEK_SET;
@@ -497,6 +510,9 @@
 	int mounted = 0;
 	int regged = 0;
 
+	pthread_spin_lock(part-part_lck);
+	part-part_refcount++;
+	pthread_spin_unlock(part-part_lck);
 	if (part != ukfs_part_na) {
 		if ((rv = process_diskdevice(devpath, part,
 		mntflags  MNT_RDONLY, devfd)) != 0)
@@ -621,7 +637,6 @@
 		rump_pub_lwp_release(rump_pub_lwp_curlwp());
 	}
 
-	ukfs_part_release(fs-ukfs_part);
 	if (fs-ukfs_devpath) {
 		rump_pub_etfs_remove(fs-ukfs_devpath);
 		free(fs-ukfs_devpath);
@@ -633,6 +648,7 @@
 		unlockdev(fs-ukfs_devfd, fs-ukfs_part);
 		close(fs-ukfs_devfd);
 	}
+	ukfs_part_release(fs-ukfs_part);
 	free(fs);
 
 	return 0;
@@ -641,9 +657,17 @@
 void
 ukfs_part_release(struct ukfs_part *part)
 {
+	int release;
 
-	if (part != ukfs_part_none  part != ukfs_part_na)
-		free(part);
+	if (part != ukfs_part_none  part != ukfs_part_na) {
+		pthread_spin_lock(part-part_lck);
+		release = --part-part_refcount == 0;
+		pthread_spin_unlock(part-part_lck);
+		if (release) {
+			pthread_spin_destroy(part-part_lck);
+			free(part);
+		}
+	}
 }
 
 #define STDCALL(ukfs, thecall)		\



CVS commit: src/lib/libukfs

2009-12-11 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Dec 11 16:47:33 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
Init ukfs__part_{na,none} statically instead of at runtime to avoid
init-order lossage from p2k/rump_smbfs, as noted by Tron.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/lib/libukfs/ukfs.c

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.43 src/lib/libukfs/ukfs.c:1.44
--- src/lib/libukfs/ukfs.c:1.43	Thu Dec  3 14:23:49 2009
+++ src/lib/libukfs/ukfs.c	Fri Dec 11 16:47:33 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.43 2009/12/03 14:23:49 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.44 2009/12/11 16:47:33 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -177,16 +177,8 @@
 	.part_devsize = RUMP_ETFS_SIZE_ENDOFF,
 };
 static struct ukfs_part ukfs__part_na;
-struct ukfs_part *ukfs_part_none;
-struct ukfs_part *ukfs_part_na;
-
-static void
-ukfs_initparts(void)
-{
-
-	ukfs_part_none = ukfs__part_none;
-	ukfs_part_na = ukfs__part_na;
-}
+struct ukfs_part *ukfs_part_none = ukfs__part_none;
+struct ukfs_part *ukfs_part_na = ukfs__part_na;
 
 int
 _ukfs_init(int version)
@@ -200,7 +192,6 @@
 		return -1;
 	}
 
-	ukfs_initparts();
 	if ((rv = rump_init()) != 0) {
 		errno = rv;
 		return -1;
@@ -225,7 +216,6 @@
 	int error = 0;
 	int devfd = -1;
 
-	ukfs_initparts();
 	if ((p = strstr(devpath, UKFS_PARTITION_SCANMAGIC)) != NULL) {
 		fprintf(stderr, ukfs: %%PART is deprecated.  use 
 		%%DISKLABEL instead\n);



CVS commit: src/lib/libukfs

2009-12-11 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Dec 11 21:20:52 UTC 2009

Modified Files:
src/lib/libukfs: Makefile ukfs.c

Log Message:
Use range locking (fnctl(F_SETLK)) instead of file locking (flock()).
This allows to mount multiple (non-overlapping) partitions from the
same disk image.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libukfs/Makefile
cvs rdiff -u -r1.44 -r1.45 src/lib/libukfs/ukfs.c

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/Makefile
diff -u src/lib/libukfs/Makefile:1.3 src/lib/libukfs/Makefile:1.4
--- src/lib/libukfs/Makefile:1.3	Wed Oct  7 20:51:00 2009
+++ src/lib/libukfs/Makefile	Fri Dec 11 21:20:52 2009
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.3 2009/10/07 20:51:00 pooka Exp $
+#	$NetBSD: Makefile,v 1.4 2009/12/11 21:20:52 pooka Exp $
 #
 
 LIB=		ukfs
-LIBDPLIBS+=	rump	${.CURDIR}/../librump		\
-		rumpvfs	${.CURDIR}/../librumpvfs
+#LIBDPLIBS+=	rump	${.CURDIR}/../librump		\
+#		rumpvfs	${.CURDIR}/../librumpvfs
 CPPFLAGS+=	-I${.CURDIR}
 
 INCS=		ukfs.h
@@ -11,5 +11,6 @@
 
 SRCS=		ukfs.c ukfs_disklabel.c
 MAN=		ukfs.3
+DBG=		-g
 
 .include bsd.lib.mk

Index: src/lib/libukfs/ukfs.c
diff -u src/lib/libukfs/ukfs.c:1.44 src/lib/libukfs/ukfs.c:1.45
--- src/lib/libukfs/ukfs.c:1.44	Fri Dec 11 16:47:33 2009
+++ src/lib/libukfs/ukfs.c	Fri Dec 11 21:20:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.44 2009/12/11 16:47:33 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.45 2009/12/11 21:20:52 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -79,6 +79,7 @@
 	int ukfs_devfd;
 	char *ukfs_devpath;
 	char *ukfs_mountpath;
+	struct ukfs_part *ukfs_part;
 };
 
 static int builddirs(const char *, mode_t,
@@ -180,6 +181,8 @@
 struct ukfs_part *ukfs_part_none = ukfs__part_none;
 struct ukfs_part *ukfs_part_na = ukfs__part_na;
 
+#define PART2LOCKSIZE(len) ((len) == RUMP_ETFS_SIZE_ENDOFF ? 0 : (len))
+
 int
 _ukfs_init(int version)
 {
@@ -387,6 +390,20 @@
 	return rv;
 }
 
+static void
+unlockdev(int fd, struct ukfs_part *part)
+{
+	struct flock flarg;
+
+	memset(flarg, 0, sizeof(flarg));
+	flarg.l_type = F_UNLCK;
+	flarg.l_whence = SEEK_SET;
+	flarg.l_start = part-part_devoff;
+	flarg.l_len = PART2LOCKSIZE(part-part_devsize);
+	if (fcntl(fd, F_SETLK, flarg) == -1)
+		warn(ukfs: cannot unlock device file);
+}
+
 /*
  * Open the disk file and flock it.  Also, if we are operation on
  * an embedded partition, find the partition offset and size from
@@ -395,12 +412,12 @@
  * We hard-fail only in two cases:
  *  1) we failed to get the partition info out (don't know what offset
  * to mount from)
- *  2) we failed to flock the source device (i.e. flock() fails,
+ *  2) we failed to flock the source device (i.e. fcntl() fails,
  * not e.g. open() before it)
  *
  * Otherwise we let the code proceed to mount and let the file system
  * throw the proper error.  The only questionable bit is that if we
- * soft-fail before flock() and mount does succeed...
+ * soft-fail before flock and mount does succeed...
  *
  * Returns: -1 error (errno reports error code)
  *   0 success
@@ -435,10 +452,25 @@
 	 * We also need to close the device for fairly obvious reasons.
 	 */
 	if (!S_ISBLK(sb.st_mode)) {
-		if (flock(devfd, LOCK_NB | (rdonly ? LOCK_SH:LOCK_EX)) == -1) {
-			warnx(ukfs_mount: cannot get %s lock on 
-			device, rdonly ? shared : exclusive);
-			rv = errno;
+		struct flock flarg;
+
+		memset(flarg, 0, sizeof(flarg));
+		flarg.l_type = rdonly ? F_RDLCK : F_WRLCK;
+		flarg.l_whence = SEEK_SET;
+		flarg.l_start = part-part_devoff;
+		flarg.l_len = PART2LOCKSIZE(part-part_devsize);
+		if (fcntl(devfd, F_SETLK, flarg) == -1) {
+			pid_t holder;
+			int sverrno;
+
+			sverrno = errno;
+			if (fcntl(devfd, F_GETLK, flarg) != 1)
+holder = flarg.l_pid;
+			else
+holder = -1;
+			warnx(ukfs_mount: cannot lock device.  held by pid %d,
+			holder);
+			rv = sverrno;
 			goto out;
 		}
 	} else {
@@ -518,10 +550,10 @@
 	fs-ukfs_cdir = ukfs_getrvp(fs);
 	pthread_spin_init(fs-ukfs_spin, PTHREAD_PROCESS_SHARED);
 	fs-ukfs_devfd = devfd;
+	fs-ukfs_part = part;
 	assert(rv == 0);
 
  out:
-	ukfs_part_release(part);
 	if (rv) {
 		if (fs) {
 			if (fs-ukfs_rvp)
@@ -534,9 +566,10 @@
 		if (regged)
 			rump_pub_etfs_remove(devpath);
 		if (devfd != -1) {
-			flock(devfd, LOCK_UN);
+			unlockdev(fs-ukfs_devfd, fs-ukfs_part);
 			close(devfd);
 		}
+		ukfs_part_release(part);
 		errno = rv;
 	}
 
@@ -588,6 +621,7 @@
 		rump_pub_lwp_release(rump_pub_lwp_curlwp());
 	}
 
+	ukfs_part_release(fs-ukfs_part);
 	if (fs-ukfs_devpath) {
 		rump_pub_etfs_remove(fs-ukfs_devpath);
 		free(fs-ukfs_devpath);
@@ -596,7 +630,7 @@
 
 	pthread_spin_destroy(fs-ukfs_spin);
 	if (fs-ukfs_devfd != -1) {
-		flock(fs-ukfs_devfd, LOCK_UN);
+		unlockdev(fs-ukfs_devfd, fs-ukfs_part);
 		close(fs-ukfs_devfd);
 	}
 	free(fs);



CVS commit: src/lib/libukfs

2009-12-11 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Dec 11 21:21:52 UTC 2009

Modified Files:
src/lib/libukfs: Makefile

Log Message:
uncommit accidental changes


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libukfs/Makefile

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/Makefile
diff -u src/lib/libukfs/Makefile:1.4 src/lib/libukfs/Makefile:1.5
--- src/lib/libukfs/Makefile:1.4	Fri Dec 11 21:20:52 2009
+++ src/lib/libukfs/Makefile	Fri Dec 11 21:21:52 2009
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.4 2009/12/11 21:20:52 pooka Exp $
+#	$NetBSD: Makefile,v 1.5 2009/12/11 21:21:52 pooka Exp $
 #
 
 LIB=		ukfs
-#LIBDPLIBS+=	rump	${.CURDIR}/../librump		\
-#		rumpvfs	${.CURDIR}/../librumpvfs
+LIBDPLIBS+=	rump	${.CURDIR}/../librump		\
+		rumpvfs	${.CURDIR}/../librumpvfs
 CPPFLAGS+=	-I${.CURDIR}
 
 INCS=		ukfs.h
@@ -11,6 +11,5 @@
 
 SRCS=		ukfs.c ukfs_disklabel.c
 MAN=		ukfs.3
-DBG=		-g
 
 .include bsd.lib.mk



CVS commit: src/lib/libukfs

2009-12-11 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sat Dec 12 00:46:04 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
fix error branch


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/lib/libukfs/ukfs.c

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.45 src/lib/libukfs/ukfs.c:1.46
--- src/lib/libukfs/ukfs.c:1.45	Fri Dec 11 21:20:52 2009
+++ src/lib/libukfs/ukfs.c	Sat Dec 12 00:46:04 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.45 2009/12/11 21:20:52 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.46 2009/12/12 00:46:04 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -566,7 +566,7 @@
 		if (regged)
 			rump_pub_etfs_remove(devpath);
 		if (devfd != -1) {
-			unlockdev(fs-ukfs_devfd, fs-ukfs_part);
+			unlockdev(devfd, part);
 			close(devfd);
 		}
 		ukfs_part_release(part);



CVS commit: src/lib/libukfs

2009-12-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Dec  3 14:23:49 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c ukfs.h ukfs_disklabel.c ukfs_int_disklabel.h

Log Message:
Improve the ukfs magicpath interface a bit:
* rename PART to DISKLABEL
* allow to take an OFFSET range to make it possible to access an image
  where there is no disklabel present
* make future extensions easier and less intrusive for the callers


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/lib/libukfs/ukfs.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libukfs/ukfs.h
cvs rdiff -u -r1.1 -r1.2 src/lib/libukfs/ukfs_disklabel.c \
src/lib/libukfs/ukfs_int_disklabel.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.42 src/lib/libukfs/ukfs.c:1.43
--- src/lib/libukfs/ukfs.c:1.42	Mon Nov 16 17:21:26 2009
+++ src/lib/libukfs/ukfs.c	Thu Dec  3 14:23:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.42 2009/11/16 17:21:26 njoly Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.43 2009/12/03 14:23:49 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -62,6 +62,7 @@
 
 #include rump/rump.h
 #include rump/rump_syscalls.h
+#include rump/rumpuser.h
 
 #include ukfs_int_disklabel.h
 
@@ -161,6 +162,32 @@
 	rump_pub_lwp_release(rump_pub_lwp_curlwp());
 }
 
+struct ukfs_part {
+	int part_type;
+	char part_labelchar;
+	off_t part_devoff;
+	off_t part_devsize;
+};
+
+enum ukfs_parttype { UKFS_PART_NONE, UKFS_PART_DISKLABEL, UKFS_PART_OFFSET };
+
+static struct ukfs_part ukfs__part_none = {
+	.part_type = UKFS_PART_NONE,
+	.part_devoff = 0,
+	.part_devsize = RUMP_ETFS_SIZE_ENDOFF,
+};
+static struct ukfs_part ukfs__part_na;
+struct ukfs_part *ukfs_part_none;
+struct ukfs_part *ukfs_part_na;
+
+static void
+ukfs_initparts(void)
+{
+
+	ukfs_part_none = ukfs__part_none;
+	ukfs_part_na = ukfs__part_na;
+}
+
 int
 _ukfs_init(int version)
 {
@@ -173,6 +200,7 @@
 		return -1;
 	}
 
+	ukfs_initparts();
 	if ((rv = rump_init()) != 0) {
 		errno = rv;
 		return -1;
@@ -190,28 +218,180 @@
 }
 
 int
-ukfs_partition_probe(char *devpath, int *partition)
+ukfs_part_probe(char *devpath, struct ukfs_part **partp)
 {
+	struct ukfs_part *part;
 	char *p;
-	int rv = 0;
+	int error = 0;
+	int devfd = -1;
+
+	ukfs_initparts();
+	if ((p = strstr(devpath, UKFS_PARTITION_SCANMAGIC)) != NULL) {
+		fprintf(stderr, ukfs: %%PART is deprecated.  use 
+		%%DISKLABEL instead\n);
+		errno = ENODEV;
+		return -1;
+	}
+
+	part = malloc(sizeof(*part));
+	if (part == NULL) {
+		errno = ENOMEM;
+		return -1;
+	}
+	part-part_type = UKFS_PART_NONE;
 
 	/*
-	 * Check for disklabel magic in pathname:
-	 * /regularpath%PART:char%\0
+	 * Check for magic in pathname:
+	 *   disklabel: /regularpath%DISKLABEL:labelchar%\0
+	 * offsets: /regularpath%OFFSET:start,end%\0
 	 */
-#define MAGICADJ(p, n) (p+sizeof(UKFS_PARTITION_SCANMAGIC)-1+n)
-	if ((p = strstr(devpath, UKFS_PARTITION_SCANMAGIC)) != NULL
-	 strlen(p) == UKFS_PARTITION_MAGICLEN
-	 *(MAGICADJ(p,1)) == '%') {
-		if (*(MAGICADJ(p,0)) = 'a' 
-		*(MAGICADJ(p,0))  'a' + UKFS_MAXPARTITIONS) {
-			*partition = *(MAGICADJ(p,0)) - 'a';
+#define MAGICADJ_DISKLABEL(p, n) (p+sizeof(UKFS_DISKLABEL_SCANMAGIC)-1+n)
+	if ((p = strstr(devpath, UKFS_DISKLABEL_SCANMAGIC)) != NULL
+	 strlen(p) == UKFS_DISKLABEL_MAGICLEN
+	 *(MAGICADJ_DISKLABEL(p,1)) == '%') {
+		if (*(MAGICADJ_DISKLABEL(p,0)) = 'a' 
+		*(MAGICADJ_DISKLABEL(p,0))  'a' + UKFS_MAXPARTITIONS) {
+			struct ukfs__disklabel dl;
+			struct ukfs__partition *pp;
+			char buf[65536];
+			char labelchar = *(MAGICADJ_DISKLABEL(p,0));
+			int partition = labelchar - 'a';
+
 			*p = '\0';
+			devfd = open(devpath, O_RDONLY);
+			if (devfd == -1) {
+error = errno;
+goto out;
+			}
+
+			/* Locate the disklabel and find the partition. */
+			if (pread(devfd, buf, sizeof(buf), 0) == -1) {
+error = errno;
+goto out;
+			}
+
+			if (ukfs__disklabel_scan(dl, buf, sizeof(buf)) != 0) {
+error = ENOENT;
+goto out;
+			}
+
+			if (dl.d_npartitions  partition) {
+error = ENOENT;
+goto out;
+			}
+
+			pp = dl.d_partitions[partition];
+			part-part_type = UKFS_PART_DISKLABEL;
+			part-part_labelchar = labelchar;
+			part-part_devoff = pp-p_offset  DEV_BSHIFT;
+			part-part_devsize = pp-p_size  DEV_BSHIFT;
 		} else {
-			rv = EINVAL;
+			error = EINVAL;
+		}
+#define MAGICADJ_OFFSET(p, n) (p+sizeof(UKFS_OFFSET_SCANMAGIC)-1+n)
+	} else if (((p = strstr(devpath, UKFS_OFFSET_SCANMAGIC)) != NULL)
+	 (strlen(p) = UKFS_OFFSET_MINLEN)) {
+		char *comma, *pers, *ep, *nptr;
+		u_quad_t val;
+
+		comma = strchr(p, ',');
+		if (comma == NULL) {
+			error = EINVAL;
+			goto out;
+		}
+		pers = strchr(comma, '%');
+		if (pers == NULL) {
+			error = EINVAL;
+			goto out;
+		}
+		*comma = '\0';
+		*pers = '\0';
+		*p = '\0';
+
+		nptr = MAGICADJ_OFFSET(p,0);
+		/* 

CVS commit: src/lib/libukfs

2009-11-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Nov 22 18:14:49 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.3

Log Message:
Update.  Especially, describe ukfs_mount_disk(), ukfs_release() flags
and return value, and remove obsolete info in BUGS.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libukfs/ukfs.3

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.3
diff -u src/lib/libukfs/ukfs.3:1.9 src/lib/libukfs/ukfs.3:1.10
--- src/lib/libukfs/ukfs.3:1.9	Mon Sep 14 20:54:34 2009
+++ src/lib/libukfs/ukfs.3	Sun Nov 22 18:14:49 2009
@@ -1,4 +1,4 @@
-.\ $NetBSD: ukfs.3,v 1.9 2009/09/14 20:54:34 pooka Exp $
+.\ $NetBSD: ukfs.3,v 1.10 2009/11/22 18:14:49 pooka Exp $
 .\
 .\ Copyright (c) 2008 Antti Kantee.  All rights reserved.
 .\
@@ -23,7 +23,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd November 28, 2008
+.Dd November 22, 2009
 .Dt UKFS 3
 .Os
 .Sh NAME
@@ -74,7 +74,11 @@
 .It Ft struct ukfs *
 .Fn ukfs_mount const char *vfsname const char *devpath \
 const char *mountpath  int mntflags void *arg size_t alen
-.It Ft void
+.It Ft struct ukfs *
+.Fn ukfs_mount_disk const char *vfsname const char *devpath \
+int partition const char *mountpath  int mntflags \
+void *arg size_t alen
+.It Ft int
 .Fn ukfs_release struct ukfs *ukfs int flags
 .El
 .Pp
@@ -173,16 +177,44 @@
 Size of said structure.
 .El
 .Pp
+The
+.Fn ukfs_mount_disk
+function must be used to mount disk-based file systems.
+It takes the same arguments as
+.Fn ukfs_mount ,
+except for an additional argument signifying the
+.Fa partition
+number.
+If the image
+.Fa devpath
+contains a disklabel, this value specifies the number of the partition
+within the image used as the file system backend.
+If
+.Fa devpath
+does not contain a disklabel, the value
+.Dv UKFS_PARTITION_NONE
+must be used to signal that the file system backend is the entire
+image.
+.Pp
 .Fn ukfs_release
-releases the resources associated with
+unmounts the file system and releases the resources associated with
 .Fa ukfs .
-If
-.Fa flags
-is
-.Dv UKFS_RELFLAG_NOUNMOUNT ,
-the file system is not unmounted.
-This is required if the file system has already been unmounted due
-to prior activity, otherwise 0 should be passed.
+The return value signals the return value of the unmount operation.
+If non-zero,
+.Fa ukfs
+will continue to remain valid.
+The possible values for flags are:
+.Bl -tag -width XUKFS_RELFLAG_NOUNMOUT -offset indent
+.It Dv UKFS_RELFLAG_NOUNMOUNT
+Do not unmount file system, just release ukfs handle.
+Release always succeeds.
+.It Dv UKFS_RELFLAG_FORCE
+Forcefully unmount the file system.
+This means that any busy nodes (due to e.g.
+.Fn ukfs_chdir )
+will be ignored.
+Release always succeeds.
+.El
 .Sh OPERATION
 .Bl -ohang
 .It Ft int
@@ -286,13 +318,11 @@
 .Nm
 should be considered experimental technology and may change without warning.
 .Sh BUGS
-Due to how the runtime linker works, it is possible to include
-support for only one file system in dynamic binaries at linktime.
-The remaining desired file systems can be loaded with
-.Fn ukfs_modload .
-Statically linked binaries do not have this limitation, but cannot use
-.Fn ukfs_modload
-at all.
-The recommended approach is to use dynamically linked binaries and load all
-file system modules with
+On Linux, dynamically linked binaries can include support for only
+one file system due to restrictions with the dynamic linker.
+If more are desired, they must be loaded at runtime using
 .Fn ukfs_modload .
+Even though
+.Nx
+does not have this restriction, portable programs should load all
+file system drivers dynamically.



CVS commit: src/lib/libukfs

2009-11-16 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Mon Nov 16 17:21:26 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
Add RTLD_LAZY to dlopen call, to make it work on Linux hosts.

ok by pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libukfs/ukfs.c

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.41 src/lib/libukfs/ukfs.c:1.42
--- src/lib/libukfs/ukfs.c:1.41	Thu Oct 15 16:41:08 2009
+++ src/lib/libukfs/ukfs.c	Mon Nov 16 17:21:26 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.41 2009/10/15 16:41:08 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.42 2009/11/16 17:21:26 njoly Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -896,7 +896,7 @@
 	struct modinfo **mi;
 	int error;
 
-	handle = dlopen(fname, RTLD_GLOBAL);
+	handle = dlopen(fname, RTLD_LAZY|RTLD_GLOBAL);
 	if (handle == NULL) {
 		const char *dlmsg = dlerror();
 		if (strstr(dlmsg, Undefined symbol))



CVS commit: src/lib/libukfs

2009-10-07 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Oct  7 20:53:38 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
fix warning whine


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libukfs/ukfs.c

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.38 src/lib/libukfs/ukfs.c:1.39
--- src/lib/libukfs/ukfs.c:1.38	Wed Oct  7 20:51:00 2009
+++ src/lib/libukfs/ukfs.c	Wed Oct  7 20:53:38 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.38 2009/10/07 20:51:00 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.39 2009/10/07 20:53:38 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -323,11 +323,15 @@
 	const char *mountpath, int mntflags, void *arg, size_t alen)
 {
 	struct ukfs *fs = NULL;
-	int rv = 0, devfd;
+	int rv = 0, devfd = -1;
 	uint64_t devoff, devsize;
 	int mounted = 0;
 	int regged = 0;
 
+	/* XXX: gcc whine */
+	devoff = 0;
+	devsize = 0;
+
 	if (partition != UKFS_PARTITION_NA)
 		process_diskdevice(devpath, partition, mntflags  MNT_RDONLY,
 		devfd, devoff, devsize);



CVS commit: src/lib/libukfs

2009-10-02 Thread Antti Kantee
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 *);



CVS commit: src/lib/libukfs

2009-09-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Sep 14 20:54:34 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.3

Log Message:
fix markup


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libukfs/ukfs.3

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.3
diff -u src/lib/libukfs/ukfs.3:1.8 src/lib/libukfs/ukfs.3:1.9
--- src/lib/libukfs/ukfs.3:1.8	Sat Apr 11 16:44:01 2009
+++ src/lib/libukfs/ukfs.3	Mon Sep 14 20:54:34 2009
@@ -1,4 +1,4 @@
-.\ $NetBSD: ukfs.3,v 1.8 2009/04/11 16:44:01 joerg Exp $
+.\ $NetBSD: ukfs.3,v 1.9 2009/09/14 20:54:34 pooka Exp $
 .\
 .\ Copyright (c) 2008 Antti Kantee.  All rights reserved.
 .\
@@ -239,7 +239,7 @@
 .It Ft int
 .Fn ukfs_lchflags struct ukfs *ukfs const char *filename u_long flags
 .It Ft int
-.Fn ukfs_utimes struct ukfs *ukfs const char *filename
+.Fn ukfs_utimes struct ukfs *ukfs const char *filename \
 const struct timeval *tptr
 .It Ft int
 .Fn ukfs_lutimes struct ukfs *ukfs const char *filename \



CVS commit: src/lib/libukfs

2009-08-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Aug  4 12:37:14 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
If opening the device fails, skip etfs registration only if it is
because of ENOENT.  Otherwise, let the file system handle it.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libukfs/ukfs.c

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.34 src/lib/libukfs/ukfs.c:1.35
--- src/lib/libukfs/ukfs.c:1.34	Mon Aug  3 15:08:37 2009
+++ src/lib/libukfs/ukfs.c	Tue Aug  4 12:37:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.34 2009/08/03 15:08:37 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.35 2009/08/04 12:37:14 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008  Antti Kantee.  All Rights Reserved.
@@ -225,6 +225,8 @@
 			devfd = -1;
 		}
 		doreg = 1;
+	} else if (errno != ENOENT) {
+		doreg = 1;
 	}
 
 	fs = malloc(sizeof(struct ukfs));



CVS commit: src/lib/libukfs

2009-08-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Aug  3 14:24:58 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
* use new etfs interface
  + attempt to register only if we can stat() the devpath.  this works
around e.g. nfs devpath, which is useless to register to etfs
XXX: the caller should decide


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libukfs/ukfs.c

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.32 src/lib/libukfs/ukfs.c:1.33
--- src/lib/libukfs/ukfs.c:1.32	Thu Jul 23 01:01:31 2009
+++ src/lib/libukfs/ukfs.c	Mon Aug  3 14:24:58 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.32 2009/07/23 01:01:31 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.33 2009/08/03 14:24:58 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008  Antti Kantee.  All Rights Reserved.
@@ -180,6 +180,8 @@
 	struct ukfs *fs = NULL;
 	int rv = 0, devfd = -1, rdonly;
 	int mounted = 0;
+	int regged = 0;
+	int doreg = 0;
 
 	/*
 	 * Try open and lock the device.  if we can't open it, assume
@@ -222,6 +224,7 @@
 			close(devfd);
 			devfd = -1;
 		}
+		doreg = 1;
 	}
 
 	fs = malloc(sizeof(struct ukfs));
@@ -239,7 +242,13 @@
 		}
 	}
 
-	rump_fakeblk_register(devpath);
+	if (doreg) {
+		rv = rump_etfs_register(devpath, devpath, RUMP_ETFS_BLK);
+		if (rv) {
+			goto out;
+		}
+		regged = 1;
+	}
 	rv = rump_sys_mount(vfsname, mountpath, mntflags, arg, alen);
 	if (rv) {
 		goto out;
@@ -254,7 +263,9 @@
 		goto out;
 	}
 
-	fs-ukfs_devpath = strdup(devpath);
+	if (regged) {
+		fs-ukfs_devpath = strdup(devpath);
+	}
 	fs-ukfs_mountpath = strdup(mountpath);
 	fs-ukfs_cdir = ukfs_getrvp(fs);
 	pthread_spin_init(fs-ukfs_spin, PTHREAD_PROCESS_SHARED);
@@ -272,6 +283,8 @@
 		}
 		if (mounted)
 			rump_sys_unmount(mountpath, MNT_FORCE);
+		if (regged)
+			rump_etfs_remove(devpath);
 		if (devfd != -1) {
 			flock(devfd, LOCK_UN);
 			close(devfd);
@@ -301,8 +314,10 @@
 		}
 	}
 
-	rump_fakeblk_deregister(fs-ukfs_devpath);
-	free(fs-ukfs_devpath);
+	if (fs-ukfs_devpath) {
+		rump_etfs_remove(fs-ukfs_devpath);
+		free(fs-ukfs_devpath);
+	}
 	free(fs-ukfs_mountpath);
 
 	pthread_spin_destroy(fs-ukfs_spin);



CVS commit: src/lib/libukfs

2009-08-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Aug  3 15:08:37 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
fix errno reporting


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/lib/libukfs/ukfs.c

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.33 src/lib/libukfs/ukfs.c:1.34
--- src/lib/libukfs/ukfs.c:1.33	Mon Aug  3 14:24:58 2009
+++ src/lib/libukfs/ukfs.c	Mon Aug  3 15:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.33 2009/08/03 14:24:58 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.34 2009/08/03 15:08:37 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008  Antti Kantee.  All Rights Reserved.
@@ -251,6 +251,7 @@
 	}
 	rv = rump_sys_mount(vfsname, mountpath, mntflags, arg, alen);
 	if (rv) {
+		rv = errno;
 		goto out;
 	}
 	mounted = 1;
@@ -274,7 +275,6 @@
 
  out:
 	if (rv) {
-		int sverrno = errno;
 		if (fs) {
 			if (fs-ukfs_rvp)
 rump_vp_rele(fs-ukfs_rvp);
@@ -289,7 +289,7 @@
 			flock(devfd, LOCK_UN);
 			close(devfd);
 		}
-		errno = sverrno;
+		errno = rv;
 	}
 
 	return fs;



CVS commit: src/lib/libukfs

2009-07-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jul 22 21:05:30 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
delint


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libukfs/ukfs.c

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.30 src/lib/libukfs/ukfs.c:1.31
--- src/lib/libukfs/ukfs.c:1.30	Wed Jul 22 20:46:34 2009
+++ src/lib/libukfs/ukfs.c	Wed Jul 22 21:05:30 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.30 2009/07/22 20:46:34 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.31 2009/07/22 21:05:30 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008  Antti Kantee.  All Rights Reserved.
@@ -164,6 +164,7 @@
 	return 0;
 }
 
+/*ARGSUSED*/
 static int
 rumpmkdir(struct ukfs *dummy, const char *path, mode_t mode)
 {



CVS commit: src/lib/libukfs

2009-05-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri May 22 08:59:53 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c

Log Message:
use compat syscalls if necessary


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libukfs/ukfs.c

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.27 src/lib/libukfs/ukfs.c:1.28
--- src/lib/libukfs/ukfs.c:1.27	Fri May 15 15:54:03 2009
+++ src/lib/libukfs/ukfs.c	Fri May 22 08:59:53 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.27 2009/05/15 15:54:03 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.28 2009/05/22 08:59:53 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008  Antti Kantee.  All Rights Reserved.
@@ -590,18 +590,57 @@
 	return rv;
 }
 
+/*
+ * If we want to use post-time_t file systems on pre-time_t hosts,
+ * we must translate the stat structure.  Since we don't currently
+ * have a general method for making compat calls in rump, special-case
+ * this one.
+ *
+ * Note that this does not allow making system calls to older rump
+ * kernels from newer hosts.
+ */
+#define VERS_TIMECHANGE 599000700
+
+static int
+needcompat(void)
+{
+
+#ifdef __NetBSD__
+	return __NetBSD_Version__  VERS_TIMECHANGE
+	 rump_getversion() = VERS_TIMECHANGE;
+#else
+	return 0;
+#endif
+}
+
 int
 ukfs_stat(struct ukfs *ukfs, const char *filename, struct stat *file_stat)
 {
+	int rv;
 
-	STDCALL(ukfs, rump_sys_stat(filename, file_stat));
+	precall(ukfs);
+	if (needcompat())
+		rv = rump_sys___stat30(filename, file_stat);
+	else
+		rv = rump_sys_stat(filename, file_stat);
+	postcall(ukfs);
+
+	return rv;
 }
 
 int
 ukfs_lstat(struct ukfs *ukfs, const char *filename, struct stat *file_stat)
 {
+	int rv;
 
-	STDCALL(ukfs, rump_sys_lstat(filename, file_stat));
+	precall(ukfs);
+	if (needcompat())
+		rv = rump_sys___lstat30(filename, file_stat);
+	else
+		rv = rump_sys_lstat(filename, file_stat);
+	postcall(ukfs);
+
+	return rv;
 }
 
 int



CVS commit: src/lib/libukfs

2009-04-26 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Apr 26 22:23:02 UTC 2009

Modified Files:
src/lib/libukfs: ukfs.c ukfs.h

Log Message:
Provide a stateful mode for readdir/read/write.  Using them gives
a measurable boost to some fs-utils commands.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libukfs/ukfs.c
cvs rdiff -u -r1.7 -r1.8 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.23 src/lib/libukfs/ukfs.c:1.24
--- src/lib/libukfs/ukfs.c:1.23	Mon Apr  6 03:27:39 2009
+++ src/lib/libukfs/ukfs.c	Sun Apr 26 22:23:01 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.c,v 1.23 2009/04/06 03:27:39 pooka Exp $	*/
+/*	$NetBSD: ukfs.c,v 1.24 2009/04/26 22:23:01 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008  Antti Kantee.  All Rights Reserved.
@@ -298,22 +298,36 @@
 	return rv;
 
 int
-ukfs_getdents(struct ukfs *ukfs, const char *dirname, off_t *off,
-	uint8_t *buf, size_t bufsize)
+ukfs_opendir(struct ukfs *ukfs, const char *dirname, struct ukfs_dircookie **c)
 {
-	struct uio *uio;
 	struct vnode *vp;
-	size_t resid;
-	kauth_cred_t cred;
-	int rv, eofflag;
+	int rv;
 
 	precall(ukfs);
 	rv = rump_namei(RUMP_NAMEI_LOOKUP, RUMP_NAMEI_LOCKLEAF, dirname,
 	NULL, vp, NULL);
 	postcall(ukfs);
-	if (rv)
-		goto out;
-		
+
+	if (rv == 0) {
+		RUMP_VOP_UNLOCK(vp, 0);
+	} else {
+		errno = rv;
+		rv = -1;
+	}
+
+	/*LINTED*/
+	*c = (struct ukfs_dircookie *)vp;
+	return rv;
+}
+
+static int
+getmydents(struct vnode *vp, off_t *off, uint8_t *buf, size_t bufsize)
+{
+	struct uio *uio;
+	size_t resid;
+	int rv, eofflag;
+	kauth_cred_t cred;
+	
 	uio = rump_uio_setup(buf, bufsize, *off, RUMPUIO_READ);
 	cred = rump_cred_suserget();
 	rv = RUMP_VOP_READDIR(vp, uio, cred, eofflag, NULL, NULL);
@@ -321,9 +335,7 @@
 	RUMP_VOP_UNLOCK(vp, 0);
 	*off = rump_uio_getoff(uio);
 	resid = rump_uio_free(uio);
-	rump_vp_rele(vp);
 
- out:
 	if (rv) {
 		errno = rv;
 		return -1;
@@ -333,6 +345,63 @@
 	return bufsize - resid;
 }
 
+/*ARGSUSED*/
+int
+ukfs_getdents_cookie(struct ukfs *ukfs, struct ukfs_dircookie *c, off_t *off,
+	uint8_t *buf, size_t bufsize)
+{
+	/*LINTED*/
+	struct vnode *vp = (struct vnode *)c;
+
+	RUMP_VOP_LOCK(vp, RUMP_LK_SHARED);
+	return getmydents(vp, off, buf, bufsize);
+}
+
+int
+ukfs_getdents(struct ukfs *ukfs, const char *dirname, off_t *off,
+	uint8_t *buf, size_t bufsize)
+{
+	struct vnode *vp;
+	int rv;
+
+	precall(ukfs);
+	rv = rump_namei(RUMP_NAMEI_LOOKUP, RUMP_NAMEI_LOCKLEAF, dirname,
+	NULL, vp, NULL);
+	postcall(ukfs);
+	if (rv) {
+		errno = rv;
+		return -1;
+	}
+
+	rv = getmydents(vp, off, buf, bufsize);
+	rump_vp_rele(vp);
+	return rv;
+}
+
+/*ARGSUSED*/
+int
+ukfs_closedir(struct ukfs *ukfs, struct ukfs_dircookie *c)
+{
+
+	/*LINTED*/
+	rump_vp_rele((struct vnode *)c);
+	return 0;
+}
+
+int
+ukfs_open(struct ukfs *ukfs, const char *filename, int flags)
+{
+	int fd;
+
+	precall(ukfs);
+	fd = rump_sys_open(filename, flags, 0);
+	postcall(ukfs);
+	if (fd == -1)
+		return -1;
+
+	return fd;
+}
+
 ssize_t
 ukfs_read(struct ukfs *ukfs, const char *filename, off_t off,
 	uint8_t *buf, size_t bufsize)
@@ -356,6 +425,14 @@
 	return xfer;
 }
 
+/*ARGSUSED*/
+ssize_t
+ukfs_read_fd(struct ukfs *ukfs, int fd, off_t off, uint8_t *buf, size_t buflen)
+{
+
+	return rump_sys_pread(fd, buf, buflen, 0, off);
+}
+
 ssize_t
 ukfs_write(struct ukfs *ukfs, const char *filename, off_t off,
 	uint8_t *buf, size_t bufsize)
@@ -383,6 +460,29 @@
 	return xfer;
 }
 
+/*ARGSUSED*/
+ssize_t
+ukfs_write_fd(struct ukfs *ukfs, int fd, off_t off, uint8_t *buf, size_t buflen,
+	int dosync)
+{
+	ssize_t xfer;
+
+	xfer = rump_sys_pwrite(fd, buf, buflen, 0, off);
+	if (xfer  0  dosync)
+		rump_sys_fsync(fd);
+
+	return xfer;
+}
+
+/*ARGSUSED*/
+int
+ukfs_close(struct ukfs *ukfs, int fd)
+{
+
+	rump_sys_close(fd);
+	return 0;
+}
+
 int
 ukfs_create(struct ukfs *ukfs, const char *filename, mode_t mode)
 {

Index: src/lib/libukfs/ukfs.h
diff -u src/lib/libukfs/ukfs.h:1.7 src/lib/libukfs/ukfs.h:1.8
--- src/lib/libukfs/ukfs.h:1.7	Tue Oct  7 23:16:59 2008
+++ src/lib/libukfs/ukfs.h	Sun Apr 26 22:23:01 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukfs.h,v 1.7 2008/10/07 23:16:59 pooka Exp $	*/
+/*	$NetBSD: ukfs.h,v 1.8 2009/04/26 22:23:01 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008  Antti Kantee.  All Rights Reserved.
@@ -41,6 +41,7 @@
 struct timeval;
 
 struct ukfs;
+struct ukfs_dircookie;
 
 #define UKFS_DEFAULTMP /
 
@@ -56,12 +57,23 @@
 			  int, void *, size_t);
 void		ukfs_release(struct ukfs *, int);
 
+int		ukfs_opendir(struct ukfs *, const char *,
+			 struct ukfs_dircookie **);
 int		ukfs_getdents(struct ukfs *, const char *, off_t *,
 			  uint8_t *, size_t);
+int		ukfs_getdents_cookie(struct ukfs *, struct ukfs_dircookie *,
+ off_t *, uint8_t *, size_t);
+int		ukfs_closedir(struct ukfs *, struct ukfs_dircookie *);
+