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);

Reply via email to