Module Name: src
Committed By: pooka
Date: Wed Oct 7 20:55:25 UTC 2009
Modified Files:
src/lib/libp2k: p2k.c p2k.h
Log Message:
Provide p2k_run_diskfs(), which acts like p2k_run_fs(), but taps
into ukfs_mount_disk() instead of ukfs_mount()
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libp2k/p2k.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libp2k/p2k.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/libp2k/p2k.c
diff -u src/lib/libp2k/p2k.c:1.18 src/lib/libp2k/p2k.c:1.19
--- src/lib/libp2k/p2k.c:1.18 Tue Oct 6 16:57:54 2009
+++ src/lib/libp2k/p2k.c Wed Oct 7 20:55:25 2009
@@ -1,9 +1,10 @@
-/* $NetBSD: p2k.c,v 1.18 2009/10/06 16:57:54 pooka Exp $ */
+/* $NetBSD: p2k.c,v 1.19 2009/10/07 20:55:25 pooka Exp $ */
/*
- * Copyright (c) 2007 Antti Kantee. All Rights Reserved.
+ * Copyright (c) 2007, 2008, 2009 Antti Kantee. All Rights Reserved.
*
- * Development of this software was supported by Google Summer of Code.
+ * 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
@@ -245,10 +246,12 @@
ukfs_setspecific(ukfs, p2m);
}
-int
-p2k_run_fs(const char *vfsname, const char *devpath, const char *mountpath,
- int mntflags, void *arg, size_t alen, uint32_t puffs_flags)
+static int
+runfs(const char *vfsname, const char *devpath, int partition,
+ const char *mountpath, int mntflags, void *arg, size_t alen,
+ uint32_t puffs_flags)
{
+ char partpath[UKFS_PARTITION_MAXPATHLEN];
char typebuf[PUFFS_TYPELEN];
struct puffs_ops *pops;
struct puffs_usermount *pu = NULL;
@@ -322,7 +325,17 @@
strlcat(typebuf, vfsname, sizeof(typebuf));
}
- pu = puffs_init(pops, devpath, typebuf, NULL, puffs_flags);
+ if (UKFS_USEPARTITION(partition)) {
+ char partbuf[UKFS_PARTITION_MAGICLEN+1];
+
+ strlcpy(partpath, devpath, sizeof(partpath));
+ snprintf(partbuf, sizeof(partbuf), "%s%c%%",
+ UKFS_PARTITION_SCANMAGIC, partition + 'a');
+ strlcat(partpath, partbuf, sizeof(partpath));
+ } else {
+ strlcpy(partpath, devpath, sizeof(partpath));
+ }
+ pu = puffs_init(pops, partpath, typebuf, NULL, puffs_flags);
if (pu == NULL)
goto out;
@@ -331,7 +344,12 @@
if (ukfs_init() == -1)
return -1;
- ukfs = ukfs_mount(vfsname, devpath, mountpath, mntflags, arg, alen);
+ if (partition != UKFS_PARTITION_NA)
+ ukfs = ukfs_mount_disk(vfsname, devpath, partition,
+ mountpath, mntflags, arg, alen);
+ else
+ ukfs = ukfs_mount(vfsname, devpath, mountpath, mntflags,
+ arg, alen);
if (ukfs == NULL)
goto out;
allocp2m(ukfs);
@@ -370,6 +388,26 @@
return rv;
}
+
+int
+p2k_run_fs(const char *vfsname, const char *devpath, const char *mountpath,
+ int mntflags, void *arg, size_t alen, uint32_t puffs_flags)
+{
+
+ return runfs(vfsname, devpath, UKFS_PARTITION_NA, mountpath,
+ mntflags, arg, alen, puffs_flags);
+}
+
+int
+p2k_run_diskfs(const char *vfsname, const char *devpath, int partition,
+ const char *mountpath, int mntflags, void *arg, size_t alen,
+ uint32_t puffs_flags)
+{
+
+ return runfs(vfsname, devpath, partition, mountpath, mntflags,
+ arg, alen, puffs_flags);
+}
+
int
p2k_fs_statvfs(struct puffs_usermount *pu, struct statvfs *sbp)
{
Index: src/lib/libp2k/p2k.h
diff -u src/lib/libp2k/p2k.h:1.2 src/lib/libp2k/p2k.h:1.3
--- src/lib/libp2k/p2k.h:1.2 Fri Aug 1 14:50:29 2008
+++ src/lib/libp2k/p2k.h Wed Oct 7 20:55:25 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: p2k.h,v 1.2 2008/08/01 14:50:29 pooka Exp $ */
+/* $NetBSD: p2k.h,v 1.3 2009/10/07 20:55:25 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -36,6 +36,8 @@
int p2k_run_fs(const char *, const char *, const char *, int,
void *, size_t, uint32_t);
+int p2k_run_diskfs(const char *, const char *, int, const char *, int,
+ void *, size_t, uint32_t);
__END_DECLS