diff --git a/sys/rump/fs/bin/Makefile b/sys/rump/fs/bin/Makefile index 3172e8685c4a..ba3bfd80ec50 100644 --- a/sys/rump/fs/bin/Makefile +++ b/sys/rump/fs/bin/Makefile @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.1 2007/08/05 22:28:01 pooka Exp $ +# $NetBSD: Makefile,v 1.2 2007/08/16 19:48:31 pooka Exp $ # .include "${.CURDIR}/../Makefile.rumpfs" -SUBDIR= ${RUMPFSLIST} +SUBDIR= ${RUMPFSLIST} fsconsole .include diff --git a/sys/rump/fs/bin/fsconsole/Makefile b/sys/rump/fs/bin/fsconsole/Makefile new file mode 100644 index 000000000000..cb05d0276032 --- /dev/null +++ b/sys/rump/fs/bin/fsconsole/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2007/08/16 19:48:31 pooka Exp $ +# + +PROG= fsconsole +RUMPFS_NOFSLIB= # defined + +LDADD+= ${RUMPFSLD_ALL} -L${NETBSDSRCDIR}/sys/rump/fs/lib/libukfs -lukfs +DPADD+= ${RUMPFSDP_ALL} +CPPFLAGS+= -I${NETBSDSRCDIR}/sys/rump/librump/rumpkern \ + -I${NETBSDSRCDIR}/sys/rump/fs/lib/libukfs + +RUMPFS_WANT= ${RUMPFSLIST} ufs + +.include diff --git a/sys/rump/fs/bin/fsconsole/fsconsole.c b/sys/rump/fs/bin/fsconsole/fsconsole.c new file mode 100644 index 000000000000..d8d3304fa5af --- /dev/null +++ b/sys/rump/fs/bin/fsconsole/fsconsole.c @@ -0,0 +1,115 @@ +/* $NetBSD: fsconsole.c,v 1.1 2007/08/16 19:48:31 pooka Exp $ */ + +/* + * Copyright (c) 2007 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by the + * Finnish Cultural Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * If you can keep a secret: THIS IS NOT FINISHED AT ALL + */ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "rump.h" +#include "ukfs.h" + +int +main(int argc, char *argv[]) +{ + uint8_t buf[8192]; + struct ukfs *fs; + struct ufs_args args; + struct dirent *dent; + int rv; + + ukfs_init(); + + if (argc != 3) { + fprintf(stderr, "usage: fsconsole fstype fsdevice\n"); + exit(1); + } + + /* XXXXXXXXXXX: this needs fs-specific handling */ + memset(&args, 0, sizeof(args)); + args.fspec = strdup(argv[2]); + fs = ukfs_mount(argv[1], argv[2], "/", 0, &args, sizeof(args)); + + printf("got fs at %p\n", fs); + + rv = ukfs_getdents(fs, "/", 0, buf, sizeof(buf)); + printf("rv %d\n", rv); + + dent = (void *)buf; + while (rv) { + printf("%s\n", dent->d_name); + rv -= _DIRENT_SIZE(dent); + dent = _DIRENT_NEXT(dent); + } + + rv = ukfs_read(fs, "/etc/passwd", 0, buf, sizeof(buf)); + printf("rv %d\n%s\n", rv, buf); + + rv = ukfs_remove(fs, "/lopinaa"); + if (rv == -1) + warn("rv %d", rv); + +#if 0 + rv = ukfs_remove(fs, "/etc/LUSIKKAPUOLI"); + if (rv == -1) + warn("rv %d", rv); +#endif + + rv = ukfs_create(fs, "/lopinaa", 0555); + if (rv == -1) + warn("rv %d", rv); + + rv = ukfs_link(fs, "/lopinaa", "/etc/LUSIKKAPUOLI"); + if (rv == -1) + warn("link rv %d", rv); + + rv = ukfs_getdents(fs, "/etc", 0, buf, sizeof(buf)); + printf("rv %d\n", rv); + + dent = (void *)buf; + while (rv) { + printf("%s\n", dent->d_name); + rv -= _DIRENT_SIZE(dent); + dent = _DIRENT_NEXT(dent); + } + + ukfs_release(fs, 1); +}