Add mknod operation to usmb, which is now required for all FUSE file

systems on OpenBSD.

ok sthen@
This commit is contained in:
helg 2017-12-12 13:41:21 +00:00
parent 818f052256
commit 8380f7ebb7
4 changed files with 61 additions and 3 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.8 2017/11/21 00:13:04 naddy Exp $
# $OpenBSD: Makefile,v 1.9 2017/12/12 13:41:21 helg Exp $
COMMENT= mount SMB shares from userland via FUSE
DISTNAME= usmb-20130204
REVISION= 5
REVISION= 6
CATEGORIES= sysutils

View File

@ -1,7 +1,16 @@
$OpenBSD: patch-usmb_c,v 1.2 2017/05/18 21:27:47 espie Exp $
$OpenBSD: patch-usmb_c,v 1.3 2017/12/12 13:41:21 helg Exp $
Index: usmb.c
--- usmb.c.orig
+++ usmb.c
@@ -141,7 +141,7 @@ static struct fuse_operations fuse_ops = {
SET_ELEMENT (.getattr, usmb_getattr),
SET_ELEMENT (.readlink, NULL),
SET_ELEMENT (.getdir, NULL),
- SET_ELEMENT (.mknod, NULL),
+ SET_ELEMENT (.mknod, usmb_mknod),
SET_ELEMENT (.mkdir, usmb_mkdir),
SET_ELEMENT (.unlink, usmb_unlink),
SET_ELEMENT (.rmdir, usmb_rmdir),
@@ -315,8 +315,8 @@ int main (int argc, char **argv)
if (umount)

View File

@ -0,0 +1,36 @@
$OpenBSD: patch-usmb_file_c,v 1.1 2017/12/12 13:41:21 helg Exp $
Index: usmb_file.c
--- usmb_file.c.orig
+++ usmb_file.c
@@ -202,6 +202,30 @@ int usmb_write (const char *filename UNUSED, const cha
}
+/* File systems must support mknod on OpenBSD */
+int usmb_mknod (const char *filename, mode_t mode, __attribute__((unused)) dev_t dev)
+{
+ char *url = make_url (filename);
+ if (NULL == url)
+ return -ENOMEM;
+
+ if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode) || S_ISSOCK(mode))
+ return -EPERM;
+
+ DEBUG (fprintf (stderr, "mknod (%s)", url));
+
+ SMBCFILE *file = smbc_getFunctionCreat (ctx) (ctx, url, mode);
+ DEBUG (fprintf (stderr, " = %p\n", (void *)file));
+ int ret = (NULL == file) ? -errno : 0;
+
+ /* File must not be open when mknod returns. */
+ if (ret == 0)
+ smbc_getFunctionClose (ctx) (ctx, file);
+ free (url);
+ return ret;
+}
+
+
int usmb_create (const char *filename, mode_t mode, struct fuse_file_info *fi)
{
char *url = make_url (filename);

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-usmb_file_h,v 1.1 2017/12/12 13:41:21 helg Exp $
Index: usmb_file.h
--- usmb_file.h.orig
+++ usmb_file.h
@@ -31,6 +31,7 @@
struct fuse_file_info *fi);
int usmb_write (const char *filename, const char *buff, size_t len, off_t off,
struct fuse_file_info *fi);
+ int usmb_mknod (const char *filename, mode_t mode, dev_t dev);
int usmb_create (const char *filename, mode_t mode,
struct fuse_file_info *fi);
int usmb_rename (const char *from, const char *to);