Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumphijack Support mount/unmount too. So, things are...



details:   https://anonhg.NetBSD.org/src/rev/b52929e30a31
branches:  trunk
changeset: 762216:b52929e30a31
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Feb 17 17:18:08 2011 +0000

description:
Support mount/unmount too.  So, things are now generally at a stage
where you can mount a file system with a userspace server *without*
it having to go through puffs.

Say, you first start a server with ffs capability and map a host
ffs image into it:

        rump_server -lrumpvfs -lrumpfs_ffs \
            -d key=/ffsimg,hostpath=ffs2.img,size=e unix:///tmp/ffsserv

Then, configure your shell to talk to the rump server:

        setenv RUMP_SERVER unix:///tmp/ffsserv
        setenv LD_PRELOAD /usr/lib/librumphijack.so

Create a mountpoint and mount the file system:

        pain-rustique:60:~> sh
        $ cd /rump
        $ ls
        dev
        $ ls -l
        total 1
        drwxr-xr-x  2 root  wheel  512 Feb 17 18:00 dev
        $ mkdir mnt
        $ mount_ffs /ffsimg /rump/mnt
        mount_ffs: Warning: realpath /ffsimg: No such file or directory
        $ df -h mnt
        Filesystem        Size       Used      Avail %Cap Mounted on
        /ffsimg           496M       380M        91M  80% /mnt
        $ du -sckh *
        192K    dev
        380M    mnt
        381M    total
        $ umount -R mnt
        $ df -h mnt
        Filesystem        Size       Used      Avail %Cap Mounted on
        rumpfs            1.0K       1.0K         0B 100% /
        $

(note, you need -R to umount due to various degrees of unsuccesful
magic it attempts to perform without it)

diffstat:

 lib/librumphijack/hijack.c |  29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)

diffs (83 lines):

diff -r 0c2e314c798b -r b52929e30a31 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Thu Feb 17 17:14:56 2011 +0000
+++ b/lib/librumphijack/hijack.c        Thu Feb 17 17:18:08 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.47 2011/02/17 15:20:10 pooka Exp $       */
+/*      $NetBSD: hijack.c,v 1.48 2011/02/17 17:18:08 pooka Exp $       */
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: hijack.c,v 1.47 2011/02/17 15:20:10 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.48 2011/02/17 17:18:08 pooka Exp $");
 
 #define __ssp_weak_name(fun) _hijack_ ## fun
 
@@ -34,8 +34,9 @@
 #include <sys/types.h>
 #include <sys/event.h>
 #include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/poll.h>
 #include <sys/socket.h>
-#include <sys/poll.h>
 #include <sys/statvfs.h>
 
 #include <rump/rumpclient.h>
@@ -85,6 +86,7 @@
        DUALCALL_UTIMES, DUALCALL_LUTIMES, DUALCALL_FUTIMES,
        DUALCALL_TRUNCATE, DUALCALL_FTRUNCATE,
        DUALCALL_FSYNC, DUALCALL_FSYNC_RANGE,
+       DUALCALL_MOUNT, DUALCALL_UNMOUNT,
        DUALCALL__NUM
 };
 
@@ -118,6 +120,7 @@
 #endif
 #define REALREAD _sys_read
 #define REALGETDENTS __getdents30
+#define REALMOUNT __mount50
 
 int REALSELECT(int, fd_set *, fd_set *, fd_set *, struct timeval *);
 int REALPOLLTS(struct pollfd *, nfds_t,
@@ -132,6 +135,7 @@
 int REALUTIMES(const char *, const struct timeval [2]);
 int REALLUTIMES(const char *, const struct timeval [2]);
 int REALFUTIMES(int, const struct timeval [2]);
+int REALMOUNT(const char *, const char *, int, void *, size_t);
 
 #define S(a) __STRING(a)
 struct sysnames {
@@ -192,6 +196,8 @@
        { DUALCALL_FTRUNCATE,   "ftruncate",    RSYS_NAME(FTRUNCATE)    },
        { DUALCALL_FSYNC,       "fsync",        RSYS_NAME(FSYNC)        },
        { DUALCALL_FSYNC_RANGE, "fsync_range",  RSYS_NAME(FSYNC_RANGE)  },
+       { DUALCALL_MOUNT,       S(REALMOUNT),   RSYS_NAME(MOUNT)        },
+       { DUALCALL_UNMOUNT,     "unmount",      RSYS_NAME(UNMOUNT)      },
 };
 #undef S
 
@@ -1532,3 +1538,20 @@
        (const char *path, off_t length),                               \
        (const char *, off_t),                                          \
        (path, length))
+
+/*
+ * Note: with mount the decisive parameter is the mount
+ * destination directory.  This is because we don't really know
+ * about the "source" directory in a generic call (and besides,
+ * it might not even exist, cf. nfs).
+ */
+PATHCALL(int, REALMOUNT, DUALCALL_MOUNT,                               \
+       (const char *type, const char *path, int flags,                 \
+           void *data, size_t dlen),                                   \
+       (const char *, const char *, int, void *, size_t),              \
+       (type, path, flags, data, dlen))
+
+PATHCALL(int, unmount, DUALCALL_UNMOUNT,                               \
+       (const char *path, int flags),                                  \
+       (const char *, int),                                            \
+       (path, flags))



Home | Main Index | Thread Index | Old Index