usmb is another FUSE file system that doesn't implement mknod, which is
now mandatory on OpenBSD. Upstream has not been updated for a few years
so I've patched this operation in myself. It's not ideal because a new
file is created and then immediately closed and reopened when an
application calls open(2) with the O_CREAT flag. The best solution
would be to implement usmb_create as a no-op and to create and open the
file in usmb_open but the FUSE dictates that the O_CREAT flag is not
passed to the file system's open method.

There are no other changes.

ok?


Index: patches/patch-usmb_c
===================================================================
RCS file: /cvs/ports/sysutils/usmb/patches/patch-usmb_c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 patch-usmb_c
--- patches/patch-usmb_c        18 May 2017 21:27:47 -0000      1.2
+++ patches/patch-usmb_c        9 Dec 2017 01:26:34 -0000
@@ -2,6 +2,15 @@ $OpenBSD: patch-usmb_c,v 1.2 2017/05/18 
 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)
Index: patches/patch-usmb_file_c
===================================================================
RCS file: patches/patch-usmb_file_c
diff -N patches/patch-usmb_file_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-usmb_file_c   9 Dec 2017 01:26:34 -0000
@@ -0,0 +1,36 @@
+$OpenBSD$
+
+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);
Index: patches/patch-usmb_file_h
===================================================================
RCS file: patches/patch-usmb_file_h
diff -N patches/patch-usmb_file_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-usmb_file_h   9 Dec 2017 01:26:34 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+
+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);


----- End forwarded message -----

Reply via email to