CVS commit: src/lib/librefuse/refuse

2023-07-13 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Fri Jul 14 02:43:50 UTC 2023

Modified Files:
src/lib/librefuse/refuse: fs.c

Log Message:
refuse(3): Fix broken 3.5, 3.6, and 3.7 APIs

These API versions were completely missing from refuse/fs.c. User programs
could request these versions and build fine, but they couldn't even
initialize a FUSE context at run time.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse/fs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse/fs.c
diff -u src/lib/librefuse/refuse/fs.c:1.1 src/lib/librefuse/refuse/fs.c:1.2
--- src/lib/librefuse/refuse/fs.c:1.1	Sat Jan 22 08:09:40 2022
+++ src/lib/librefuse/refuse/fs.c	Fri Jul 14 02:43:50 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: fs.c,v 1.1 2022/01/22 08:09:40 pho Exp $ */
+/* $NetBSD: fs.c,v 1.2 2023/07/14 02:43:50 pho Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: fs.c,v 1.1 2022/01/22 08:09:40 pho Exp $");
+__RCSID("$NetBSD: fs.c,v 1.2 2023/07/14 02:43:50 pho Exp $");
 #endif /* !lint */
 
 /*
@@ -154,6 +154,7 @@ fuse_fs_getattr_v30(struct fuse_fs* fs, 
 return -ENOSYS
 CALL_GETATTR(30);
 CALL_GETATTR(34);
+CALL_GETATTR(35);
 CALL_GETATTR(38);
 #undef CALL_GETATTR
 default:
@@ -190,6 +191,7 @@ fuse_fs_fgetattr(struct fuse_fs* fs, con
 
 case 30:
 case 34:
+case 35:
 case 38:
 return fuse_fs_getattr_v30(fs, path, buf, fi);
 default:
@@ -231,6 +233,7 @@ fuse_fs_rename_v30(struct fuse_fs* fs, c
 return -ENOSYS
 CALL_RENAME(30);
 CALL_RENAME(34);
+CALL_RENAME(35);
 CALL_RENAME(38);
 #undef CALL_RENAME
 default:
@@ -258,6 +261,7 @@ fuse_fs_unlink(struct fuse_fs* fs, const
 CALL_UNLINK(29);
 CALL_UNLINK(30);
 CALL_UNLINK(34);
+CALL_UNLINK(35);
 CALL_UNLINK(38);
 #undef CALL_UNLINK
 default:
@@ -285,6 +289,7 @@ fuse_fs_rmdir(struct fuse_fs* fs, const 
 CALL_RMDIR(29);
 CALL_RMDIR(30);
 CALL_RMDIR(34);
+CALL_RMDIR(35);
 CALL_RMDIR(38);
 #undef CALL_RMDIR
 default:
@@ -312,6 +317,7 @@ fuse_fs_symlink(struct fuse_fs* fs, cons
 CALL_SYMLINK(29);
 CALL_SYMLINK(30);
 CALL_SYMLINK(34);
+CALL_SYMLINK(35);
 CALL_SYMLINK(38);
 #undef CALL_SYMLINK
 default:
@@ -339,6 +345,7 @@ fuse_fs_link(struct fuse_fs* fs, const c
 CALL_LINK(29);
 CALL_LINK(30);
 CALL_LINK(34);
+CALL_LINK(35);
 CALL_LINK(38);
 #undef CALL_LINK
 default:
@@ -374,6 +381,7 @@ fuse_fs_release(struct fuse_fs* fs, cons
 CALL_RELEASE(29);
 CALL_RELEASE(30);
 CALL_RELEASE(34);
+CALL_RELEASE(35);
 CALL_RELEASE(38);
 #undef CALL_RELEASE
 default:
@@ -409,6 +417,7 @@ fuse_fs_open(struct fuse_fs* fs, const c
 CALL_OPEN(29);
 CALL_OPEN(30);
 CALL_OPEN(34);
+CALL_OPEN(35);
 CALL_OPEN(38);
 #undef CALL_OPEN
 default:
@@ -445,6 +454,7 @@ fuse_fs_read(struct fuse_fs* fs, const c
 CALL_READ(29);
 CALL_READ(30);
 CALL_READ(34);
+CALL_READ(35);
 CALL_READ(38);
 #undef CALL_READ
 default:
@@ -476,6 +486,7 @@ fuse_fs_read_buf(struct fuse_fs* fs, con
 CALL_READ_BUF(29);
 CALL_READ_BUF(30);
 CALL_READ_BUF(34);
+CALL_READ_BUF(35);
 CALL_READ_BUF(38);
 #undef CALL_READ_BUF
 default:
@@ -512,6 +523,7 @@ fuse_fs_write(struct fuse_fs* fs, const 
 CALL_WRITE(29);
 CALL_WRITE(30);
 CALL_WRITE(34);
+CALL_WRITE(35);
 CALL_WRITE(38);
 #undef CALL_WRITE
 default:
@@ -543,6 +555,7 @@ fuse_fs_write_buf(struct fuse_fs* fs, co
 CALL_WRITE_BUF(29);
 CALL_WRITE_BUF(30);
 CALL_WRITE_BUF(34);
+CALL_WRITE_BUF(35);
 CALL_WRITE_BUF(38);
 #undef CALL_WRITE_BUF
 default:
@@ -578,6 +591,7 @@ fuse_fs_fsync(struct fuse_fs* fs, const 
 CALL_FSYNC(29);
 CALL_FSYNC(30);
 CALL_FSYNC(34);
+CALL_FSYNC(35);
 CALL_FSYNC(38);
 #undef CALL_FSYNC
 default:
@@ -613,6 +627,7 @@ fuse_fs_flush(struct fuse_fs* fs, const 
 CALL_FLUSH(29);
 CALL_FLUSH(30);
 CALL_FLUSH(34);
+CALL_FLUSH(35);
 CALL_FLUSH(38);
 #undef CALL_FLUSH
 default:
@@ -706,6 +721,7 @@ fuse_fs_statfs(struct fuse_fs* fs, const
 CALL_STATFS(29);
 CALL_STATFS(30);
 CALL_STATFS(34);
+CALL_STATFS(35);
 CALL_STATFS(38);
 #undef CALL_STATFS
 default:
@@ -737,6 +753,7 @@ fuse_fs_opendir(struct fuse_fs* fs, cons
 CALL_OPENDIR(29);
 CALL_OPENDIR(30);
 CALL_OPENDIR(34);
+CALL_OPENDIR(35);
 CALL_OPENDIR(38);
 #undef 

CVS commit: src/lib/librefuse/refuse

2023-07-13 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Fri Jul 14 02:43:50 UTC 2023

Modified Files:
src/lib/librefuse/refuse: fs.c

Log Message:
refuse(3): Fix broken 3.5, 3.6, and 3.7 APIs

These API versions were completely missing from refuse/fs.c. User programs
could request these versions and build fine, but they couldn't even
initialize a FUSE context at run time.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse/fs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2023-04-21 Thread David Brownlee
Module Name:src
Committed By:   abs
Date:   Fri Apr 21 19:29:32 UTC 2023

Modified Files:
src/lib/librefuse: fuse.h

Log Message:
Fix incorrect test for FUSE_USE_VERSION 34

(Thanks to Mark Davies for report)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/librefuse/fuse.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/librefuse/fuse.h
diff -u src/lib/librefuse/fuse.h:1.34 src/lib/librefuse/fuse.h:1.35
--- src/lib/librefuse/fuse.h:1.34	Sat Jan 22 08:09:39 2022
+++ src/lib/librefuse/fuse.h	Fri Apr 21 19:29:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.34 2022/01/22 08:09:39 pho Exp $ */
+/* $NetBSD: fuse.h,v 1.35 2023/04/21 19:29:31 abs Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -637,7 +637,7 @@ fuse_new(struct fuse_args *args, const s
 #		define fuse_parse_cmdline	fuse_parse_cmdline_v30
 
 /* = FUSE 3.4 = */
-#	elif FUSE_USE_VERSION >= 34
+#	elif FUSE_USE_VERSION == 34
 		/* Types */
 #		define _FUSE_OP_VERSION__	34
 #		define fuse_fill_dir_t		fuse_fill_dir_t_v30



CVS commit: src/lib/librefuse

2023-04-21 Thread David Brownlee
Module Name:src
Committed By:   abs
Date:   Fri Apr 21 19:29:32 UTC 2023

Modified Files:
src/lib/librefuse: fuse.h

Log Message:
Fix incorrect test for FUSE_USE_VERSION 34

(Thanks to Mark Davies for report)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/librefuse/fuse.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-28 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jan 29 00:03:42 UTC 2022

Modified Files:
src/lib/librefuse: refuse_log.c

Log Message:
librefuse: default_log_func is __printflike


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse_log.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse_log.c
diff -u src/lib/librefuse/refuse_log.c:1.1 src/lib/librefuse/refuse_log.c:1.2
--- src/lib/librefuse/refuse_log.c:1.1	Sat Jan 22 07:39:22 2022
+++ src/lib/librefuse/refuse_log.c	Sat Jan 29 00:03:41 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: refuse_log.c,v 1.1 2022/01/22 07:39:22 pho Exp $ */
+/* $NetBSD: refuse_log.c,v 1.2 2022/01/29 00:03:41 tnn Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse_log.c,v 1.1 2022/01/22 07:39:22 pho Exp $");
+__RCSID("$NetBSD: refuse_log.c,v 1.2 2022/01/29 00:03:41 tnn Exp $");
 #endif /* !lint */
 
 #include 
@@ -41,7 +41,7 @@ __RCSID("$NetBSD: refuse_log.c,v 1.1 202
 #endif
 #include 
 
-static void
+static void  __printflike(2, 0)
 default_log_func(enum fuse_log_level level __attribute__((__unused__)),
  const char *fmt, va_list ap) {
 /* This function needs to be thread-safe. Calling vfprintf(3)



CVS commit: src/lib/librefuse

2022-01-28 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jan 29 00:03:42 UTC 2022

Modified Files:
src/lib/librefuse: refuse_log.c

Log Message:
librefuse: default_log_func is __printflike


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse_log.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 23 21:07:28 UTC 2022

Modified Files:
src/lib/librefuse: refuse_compat.c
src/lib/librefuse/refuse: v30.c

Log Message:
librefuse: fix lint warnings about void function returning a value

lib/librefuse/refuse_compat.c(155):
error: void function fuse_unmount cannot return value [213]
lib/librefuse/refuse/v30.c(57):
error: void function fuse_destroy_v30 cannot return value [213]


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/librefuse/refuse_compat.c
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse/v30.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse_compat.c
diff -u src/lib/librefuse/refuse_compat.c:1.2 src/lib/librefuse/refuse_compat.c:1.3
--- src/lib/librefuse/refuse_compat.c:1.2	Sat Jan 22 08:09:39 2022
+++ src/lib/librefuse/refuse_compat.c	Sun Jan 23 21:07:28 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: refuse_compat.c,v 1.2 2022/01/22 08:09:39 pho Exp $ */
+/* $NetBSD: refuse_compat.c,v 1.3 2022/01/23 21:07:28 rillig Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse_compat.c,v 1.2 2022/01/22 08:09:39 pho Exp $");
+__RCSID("$NetBSD: refuse_compat.c,v 1.3 2022/01/23 21:07:28 rillig Exp $");
 #endif /* !lint */
 
 #include 
@@ -152,7 +152,7 @@ __warn_references(
 " include  for correct reference")
 void
 fuse_unmount(struct fuse* fuse) {
-return fuse_unmount_v30(fuse);
+fuse_unmount_v30(fuse);
 }
 
 /* librefuse once had a function fuse_unmount_compat22() which was an

Index: src/lib/librefuse/refuse/v30.c
diff -u src/lib/librefuse/refuse/v30.c:1.1 src/lib/librefuse/refuse/v30.c:1.2
--- src/lib/librefuse/refuse/v30.c:1.1	Sat Jan 22 08:09:40 2022
+++ src/lib/librefuse/refuse/v30.c	Sun Jan 23 21:07:28 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: v30.c,v 1.1 2022/01/22 08:09:40 pho Exp $ */
+/* $NetBSD: v30.c,v 1.2 2022/01/23 21:07:28 rillig Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: v30.c,v 1.1 2022/01/22 08:09:40 pho Exp $");
+__RCSID("$NetBSD: v30.c,v 1.2 2022/01/23 21:07:28 rillig Exp $");
 #endif /* !lint */
 
 #include 
@@ -54,7 +54,7 @@ fuse_new_v30(struct fuse_args *args,
 
 void
 fuse_destroy_v30(struct fuse *fuse) {
-return __fuse_destroy(fuse);
+__fuse_destroy(fuse);
 }
 
 int



CVS commit: src/lib/librefuse

2022-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 23 21:07:28 UTC 2022

Modified Files:
src/lib/librefuse: refuse_compat.c
src/lib/librefuse/refuse: v30.c

Log Message:
librefuse: fix lint warnings about void function returning a value

lib/librefuse/refuse_compat.c(155):
error: void function fuse_unmount cannot return value [213]
lib/librefuse/refuse/v30.c(57):
error: void function fuse_destroy_v30 cannot return value [213]


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/librefuse/refuse_compat.c
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse/v30.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse/refuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 13:25:55 UTC 2022

Modified Files:
src/lib/librefuse/refuse: buf.c

Log Message:
Use sysconf(_SC_PAGESIZE) instead of PAGE_SIZE

It broke build on platforms where PAGE_SIZE was not defined in
.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse/buf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse/buf.c
diff -u src/lib/librefuse/refuse/buf.c:1.1 src/lib/librefuse/refuse/buf.c:1.2
--- src/lib/librefuse/refuse/buf.c:1.1	Sat Jan 22 07:54:57 2022
+++ src/lib/librefuse/refuse/buf.c	Sat Jan 22 13:25:55 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.c,v 1.1 2022/01/22 07:54:57 pho Exp $ */
+/* $NetBSD: buf.c,v 1.2 2022/01/22 13:25:55 pho Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -31,13 +31,12 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: buf.c,v 1.1 2022/01/22 07:54:57 pho Exp $");
+__RCSID("$NetBSD: buf.c,v 1.2 2022/01/22 13:25:55 pho Exp $");
 #endif /* !lint */
 
 #include 
 #include 
 #include 
-#include  /* for PAGE_SIZE */
 #include 
 #include 
 #include 
@@ -165,7 +164,7 @@ fuse_buf_copy_fd_to_fd(const struct fuse
 ssize_t total = 0;
 struct fuse_buf tmp;
 
-tmp.size  = PAGE_SIZE;
+tmp.size  = (size_t)sysconf(_SC_PAGESIZE);
 tmp.flags = (enum fuse_buf_flags)0;
 tmp.mem   = malloc(tmp.size);
 



CVS commit: src/lib/librefuse/refuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 13:25:55 UTC 2022

Modified Files:
src/lib/librefuse/refuse: buf.c

Log Message:
Use sysconf(_SC_PAGESIZE) instead of PAGE_SIZE

It broke build on platforms where PAGE_SIZE was not defined in
.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse/buf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:07:02 UTC 2022

Modified Files:
src/lib/librefuse: refuse.c

Log Message:
Zero-clear the fuse_context in fuse_destroy(3)


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.112 src/lib/librefuse/refuse.c:1.113
--- src/lib/librefuse/refuse.c:1.112	Sat Jan 22 08:05:35 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 08:07:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse.c,v 1.112 2022/01/22 08:05:35 pho Exp $	*/
+/*	$NetBSD: refuse.c,v 1.113 2022/01/22 08:07:02 pho Exp $	*/
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.112 2022/01/22 08:05:35 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.113 2022/01/22 08:07:02 pho Exp $");
 #endif /* !lint */
 
 #include 
@@ -207,6 +207,19 @@ create_context_key(void)
 #endif
 }
 
+/* struct fuse_context is potentially reused among different
+ * invocations of fuse_new() / fuse_destroy() pair. Clear its content
+ * on fuse_destroy() so that no dangling pointers remain in the
+ * context. */
+static void
+clear_context(void)
+{
+	struct fuse_context	*ctx;
+
+	ctx = fuse_get_context();
+	memset(ctx, 0, sizeof(*ctx));
+}
+
 static void
 delete_context_key(void)
 {   
@@ -1384,6 +1397,7 @@ fuse_destroy(struct fuse *fuse)
 	 * threads exist
 	 */
 
+	clear_context();
 	delete_context_key();
 	/* XX: missing stuff */
 	free(fuse);



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:07:02 UTC 2022

Modified Files:
src/lib/librefuse: refuse.c

Log Message:
Zero-clear the fuse_context in fuse_destroy(3)


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:06:21 UTC 2022

Modified Files:
src/lib/librefuse: fuse.h

Log Message:
Add some missing struct fields, structs, and constants that are part of the API


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/librefuse/fuse.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/librefuse/fuse.h
diff -u src/lib/librefuse/fuse.h:1.32 src/lib/librefuse/fuse.h:1.33
--- src/lib/librefuse/fuse.h:1.32	Sat Jan 22 08:03:32 2022
+++ src/lib/librefuse/fuse.h	Sat Jan 22 08:06:21 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.32 2022/01/22 08:03:32 pho Exp $ */
+/* $NetBSD: fuse.h,v 1.33 2022/01/22 08:06:21 pho Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -30,6 +30,7 @@
 #ifndef FUSE_H_
 #define FUSE_H_	20211204
 
+#include 
 #include 
 #include 
 #include 
@@ -94,27 +95,36 @@ extern "C" {
 #endif
 
 struct fuse;
-struct fuse_args; /* XXXsupportme */
 
 struct fuse_file_info {
 	int32_t		flags;
-	uint32_t	fh_old;
-	int32_t		writepage;
+	uint32_t	fh_old;			/* Removed as of FUSE 3.0. */
+	int32_t		writepage:1;
 	uint32_t	direct_io:1;
 	uint32_t	keep_cache:1;
 	uint32_t	flush:1;
-	uint32_t	padding:29;
+	uint32_t	nonseekable:1;		/* Added on FUSE 2.8. */
+	uint32_t	flock_release:1;	/* Added on FUSE 2.9. */
+	uint32_t	cache_readdir:1;	/* Added on FUSE 3.5. */
+	uint32_t	padding:26;
 	uint64_t	fh;
-	uint64_t	lock_owner;
+	uint64_t	lock_owner;		/* Added on FUSE 2.6. */
+	uint32_t	poll_events;		/* Added on FUSE 3.0. */
 };
 
 struct fuse_conn_info {
-	uint32_t proto_major;
-	uint32_t proto_minor;
-	uint32_t async_read;
-	uint32_t max_write;
-	uint32_t max_readahead;
-	uint32_t reserved[27];
+	uint32_t	proto_major;
+	uint32_t	proto_minor;
+	uint32_t	async_read;		/* Removed as of FUSE 3.0. */
+	uint32_t	max_write;
+	uint32_t	max_read;		/* Added on FUSE 3.0. */
+	uint32_t	max_readahead;
+	uint32_t	capable;		/* Added on FUSE 2.8. */
+	uint32_t	want;			/* Added on FUSE 2.8. */
+	uint32_t	max_background;		/* Added on FUSE 3.0. */
+	uint32_t	congestion_threshold;	/* Added on FUSE 3.0. */
+	uint32_t	time_gran;		/* Added on FUSE 3.0. */
+	uint32_t	reserved[22];
 };
 
 /* equivalent'ish of puffs_cc */
@@ -124,6 +134,78 @@ struct fuse_context {
 	gid_t		gid;
 	pid_t		pid;
 	void		*private_data;
+	mode_t		umask;			/* Added on FUSE 2.8. */
+};
+
+/* Capability bits for fuse_conn_info.capable and
+ * fuse_conn_info.want */
+#define FUSE_CAP_ASYNC_READ		(1 << 0)
+#define FUSE_CAP_POSIX_LOCKS		(1 << 1)
+#define FUSE_CAP_ATOMIC_O_TRUNC		(1 << 3)
+#define FUSE_CAP_EXPORT_SUPPORT		(1 << 4)
+#define FUSE_CAP_BIG_WRITES		(1 << 5)	/* Removed as of FUSE 3.0. */
+#define FUSE_CAP_DONT_MASK		(1 << 6)
+#define FUSE_CAP_SPLICE_WRITE		(1 << 7)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_SPLICE_MOVE		(1 << 8)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_SPLICE_READ		(1 << 9)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_FLOCK_LOCKS		(1 << 10)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_IOCTL_DIR		(1 << 11)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_AUTO_INVAL_DATA	(1 << 12)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_READDIRPLUS		(1 << 13)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_READDIRPLUS_AUTO	(1 << 14)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_ASYNC_DIO		(1 << 15)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_WRITEBACK_CACHE	(1 << 16)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_NO_OPEN_SUPPORT	(1 << 17)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_PARALLEL_DIROPS	(1 << 18)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_POSIX_ACL		(1 << 19)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_HANDLE_KILLPRIV	(1 << 20)	/* Added on FUSE 3.0. */
+#define FUSE_CAP_CACHE_SYMLINKS		(1 << 23)	/* Added on FUSE 3.10. */
+#define FUSE_CAP_NO_OPENDIR_SUPPORT	(1 << 24)	/* Added on FUSE 3.5. */
+
+/* ioctl flags */
+#define FUSE_IOCTL_COMPAT	(1 << 0)
+#define FUSE_IOCTL_UNRESTRICTED	(1 << 1)
+#define FUSE_IOCTL_RETRY	(1 << 2)
+#define FUSE_IOCTL_DIR		(1 << 4)	/* Added on FUSE 2.9. */
+#define FUSE_IOCTL_MAX_IOV	256
+
+/* readdir() flags, appeared on FUSE 3.0. */
+enum fuse_readdir_flags {
+	FUSE_READDIR_PLUS	= (1 << 0),
+};
+enum fuse_fill_dir_flags {
+	FUSE_FILL_DIR_PLUS	= (1 << 1),
+};
+
+/* Configuration of the high-level API, appeared on FUSE 3.0. */
+struct fuse_config {
+	int		set_gid;
+	unsigned int	gid;
+	int		set_uid;
+	unsigned int	uid;
+	int		set_mode;
+	unsigned int	umask;
+	double		entry_timeout;
+	double		negative_timeout;
+	double		attr_timeout;
+	int		intr;
+	int		intr_signal;
+	int		remember;
+	int		hard_remove;
+	int		use_ino;
+	int		readdir_ino;
+	int		direct_io;
+	int		kernel_cache;
+	int		auto_cache;
+	int		ac_attr_timeout_set;
+	double		ac_attr_timeout;
+	int		nullpath_ok;
+};
+
+/* Configuration of fuse_loop_mt(), appeared on FUSE 3.2. */
+struct fuse_loop_config {
+	int		clone_fd;
+	unsigned int	max_idle_threads;
 };
 
 /**



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:06:21 UTC 2022

Modified Files:
src/lib/librefuse: fuse.h

Log Message:
Add some missing struct fields, structs, and constants that are part of the API


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/librefuse/fuse.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:05:36 UTC 2022

Modified Files:
src/lib/librefuse: fuse_internal.h refuse.c refuse_lowlevel.c

Log Message:
Support the FUSE option -ho

It is supposed to print a help message without the usage
line. Although it is deprecated and has been removed as of FUSE 3.0,
filesystems in the wild still use it.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/librefuse/fuse_internal.h
cvs rdiff -u -r1.111 -r1.112 src/lib/librefuse/refuse.c
cvs rdiff -u -r1.2 -r1.3 src/lib/librefuse/refuse_lowlevel.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/fuse_internal.h
diff -u src/lib/librefuse/fuse_internal.h:1.3 src/lib/librefuse/fuse_internal.h:1.4
--- src/lib/librefuse/fuse_internal.h:1.3	Sat Jan 22 08:01:12 2022
+++ src/lib/librefuse/fuse_internal.h	Sat Jan 22 08:05:35 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse_internal.h,v 1.3 2022/01/22 08:01:12 pho Exp $ */
+/* $NetBSD: fuse_internal.h,v 1.4 2022/01/22 08:05:35 pho Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -44,6 +44,11 @@
 extern "C" {
 #endif
 
+enum refuse_show_help_variant {
+	REFUSE_SHOW_HELP_FULL		= 1,
+	REFUSE_SHOW_HELP_NO_HEADER	= 2,
+};
+
 /* Internal functions, hidden from users */
 __BEGIN_HIDDEN_DECLS
 int __fuse_set_signal_handlers(struct fuse* fuse);

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.111 src/lib/librefuse/refuse.c:1.112
--- src/lib/librefuse/refuse.c:1.111	Sat Jan 22 08:03:32 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 08:05:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse.c,v 1.111 2022/01/22 08:03:32 pho Exp $	*/
+/*	$NetBSD: refuse.c,v 1.112 2022/01/22 08:05:35 pho Exp $	*/
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.111 2022/01/22 08:03:32 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.112 2022/01/22 08:05:35 pho Exp $");
 #endif /* !lint */
 
 #include 
@@ -1157,11 +1157,17 @@ fuse_main_real(int argc, char **argv, co
 	}
 
 	if (opts.show_help) {
-		if (args.argv[0] != NULL && args.argv[0][0] != '\0') {
-			/* argv[0] being empty means that the application doesn't
-			 * want us to print the usage string.
-			 */
-			printf("Usage: %s [options] mountpoint\n\n", args.argv[0]);
+		switch (opts.show_help) {
+		case REFUSE_SHOW_HELP_FULL:
+			if (args.argv[0] != NULL && args.argv[0][0] != '\0') {
+/* argv[0] being empty means that the application doesn't
+ * want us to print the usage string.
+ */
+printf("Usage: %s [options] mountpoint\n\n", args.argv[0]);
+			}
+			break;
+		case REFUSE_SHOW_HELP_NO_HEADER:
+			break;
 		}
 		fuse_cmdline_help();
 		rv = 0;

Index: src/lib/librefuse/refuse_lowlevel.c
diff -u src/lib/librefuse/refuse_lowlevel.c:1.2 src/lib/librefuse/refuse_lowlevel.c:1.3
--- src/lib/librefuse/refuse_lowlevel.c:1.2	Sat Dec  4 06:42:39 2021
+++ src/lib/librefuse/refuse_lowlevel.c	Sat Jan 22 08:05:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse_lowlevel.c,v 1.2 2021/12/04 06:42:39 pho Exp $	*/
+/*	$NetBSD: refuse_lowlevel.c,v 1.3 2022/01/22 08:05:35 pho Exp $	*/
 
 /*
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse_lowlevel.c,v 1.2 2021/12/04 06:42:39 pho Exp $");
+__RCSID("$NetBSD: refuse_lowlevel.c,v 1.3 2022/01/22 08:05:35 pho Exp $");
 #endif /* !lint */
 
 #include 
@@ -45,8 +45,9 @@ __RCSID("$NetBSD: refuse_lowlevel.c,v 1.
 	{ t, offsetof(struct fuse_cmdline_opts, p), v }
 
 static struct fuse_opt fuse_lowlevel_opts[] = {
-	REFUSE_LOWLEVEL_OPT("-h"   , show_help   , 1),
-	REFUSE_LOWLEVEL_OPT("--help"   , show_help   , 1),
+	REFUSE_LOWLEVEL_OPT("-h"   , show_help   , REFUSE_SHOW_HELP_FULL),
+	REFUSE_LOWLEVEL_OPT("--help"   , show_help   , REFUSE_SHOW_HELP_FULL),
+	REFUSE_LOWLEVEL_OPT("-ho"  , show_help   , REFUSE_SHOW_HELP_NO_HEADER),
 	REFUSE_LOWLEVEL_OPT("-V"   , show_version, 1),
 	REFUSE_LOWLEVEL_OPT("--version", show_version, 1),
 	REFUSE_LOWLEVEL_OPT("-d"   , debug   , 1),



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:05:36 UTC 2022

Modified Files:
src/lib/librefuse: fuse_internal.h refuse.c refuse_lowlevel.c

Log Message:
Support the FUSE option -ho

It is supposed to print a help message without the usage
line. Although it is deprecated and has been removed as of FUSE 3.0,
filesystems in the wild still use it.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/librefuse/fuse_internal.h
cvs rdiff -u -r1.111 -r1.112 src/lib/librefuse/refuse.c
cvs rdiff -u -r1.2 -r1.3 src/lib/librefuse/refuse_lowlevel.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:03:32 UTC 2022

Modified Files:
src/lib/librefuse: fuse.h fuse_lowlevel.h refuse.c

Log Message:
Implement some missing functions that are part of the API


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/librefuse/fuse.h
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/fuse_lowlevel.h
cvs rdiff -u -r1.110 -r1.111 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/fuse.h
diff -u src/lib/librefuse/fuse.h:1.31 src/lib/librefuse/fuse.h:1.32
--- src/lib/librefuse/fuse.h:1.31	Sat Jan 22 08:02:49 2022
+++ src/lib/librefuse/fuse.h	Sat Jan 22 08:03:32 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.31 2022/01/22 08:02:49 pho Exp $ */
+/* $NetBSD: fuse.h,v 1.32 2022/01/22 08:03:32 pho Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -195,8 +195,6 @@ struct fuse_operations {
 
 struct fuse *fuse_new(struct fuse_args *,
 	const struct fuse_operations *, size_t, void *);
-/* Invalidate cache for a given path. Appeared on FUSE 3.2. */
-int fuse_invalidate_path(struct fuse *fuse, const char *path);
 
 int fuse_mount(struct fuse *, const char *);
 void fuse_unmount(struct fuse *);
@@ -205,9 +203,12 @@ int fuse_main_real(int, char **, const s
 /* Functions that have existed since the beginning and have never
  * changed between API versions. */
 int fuse_loop(struct fuse *);
-struct fuse_context *fuse_get_context(void);
 void fuse_exit(struct fuse *);
 void fuse_destroy(struct fuse *);
+struct fuse_context *fuse_get_context(void);
+
+/* Print available library options. Appeared on FUSE 3.1. */
+void fuse_lib_help(struct fuse_args *args);
 
 /* Daemonize the calling process. Appeared on FUSE 2.6.
  *
@@ -215,6 +216,13 @@ void fuse_destroy(struct fuse *);
  * the time when FUSE_H_ < 20211204. */
 int fuse_daemonize(int foreground) __RENAME(fuse_daemonize_rev1);
 
+/* Check if a request has been interrupted. Appeared on FUSE 2.6. */
+int fuse_interrupted(void);
+
+/* Invalidate cache for a given path. Appeared on FUSE 3.2. */
+int fuse_invalidate_path(struct fuse *fuse, const char *path);
+
+/* Get the version number of the library. Appeared on FUSE 2.7. */
 int fuse_version(void);
 
 #if FUSE_USE_VERSION == 22
@@ -230,6 +238,25 @@ void fuse_unmount_compat22(const char *)
 #define fuse_main(argc, argv, op) \
 fuse_main_real(argc, argv, op, sizeof(*(op)), NULL)
 #endif
+/* Get the version string of the library. Appeared on FUSE 3.0. */
+const char *fuse_pkgversion(void);
+
+/* Get the current supplementary group IDs for the current request, or
+ * return -errno on failure. Appeared on FUSE 2.8. */
+int fuse_getgroups(int size, gid_t list[]);
+
+/* Start the cleanup thread when using option "-oremember". Appeared
+ * on FUSE 2.9. */
+int fuse_start_cleanup_thread(struct fuse *fuse);
+
+/* Stop the cleanup thread when using "-oremember". Appeared on FUSE
+ * 2.9. */
+void fuse_stop_cleanup_thread(struct fuse *fuse);
+
+/* Iterate over cache removing stale entries, used in conjunction with
+ * "-oremember". Return the number of seconds until the next
+ * cleanup. Appeared on FUSE 2.9. */
+int fuse_clean_cache(struct fuse *fuse);
 
 #ifdef __cplusplus
 }

Index: src/lib/librefuse/fuse_lowlevel.h
diff -u src/lib/librefuse/fuse_lowlevel.h:1.1 src/lib/librefuse/fuse_lowlevel.h:1.2
--- src/lib/librefuse/fuse_lowlevel.h:1.1	Sun Nov 20 13:26:28 2016
+++ src/lib/librefuse/fuse_lowlevel.h	Sat Jan 22 08:03:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fuse_lowlevel.h,v 1.1 2016/11/20 13:26:28 pho Exp $	*/
+/*	$NetBSD: fuse_lowlevel.h,v 1.2 2022/01/22 08:03:32 pho Exp $	*/
 
 /*
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -49,7 +49,12 @@ struct fuse_cmdline_opts {
 };
 
 int fuse_parse_cmdline(struct fuse_args *args, struct fuse_cmdline_opts *opts);
+/* Print low-level version information to stdout. Appeared on FUSE
+ * 3.0. */
 void fuse_lowlevel_version(void);
+
+/* Print available options for fuse_parse_cmdline(). Appeared on FUSE
+ * 3.0. */
 void fuse_cmdline_help(void);
 
 #ifdef __cplusplus

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.110 src/lib/librefuse/refuse.c:1.111
--- src/lib/librefuse/refuse.c:1.110	Sat Jan 22 08:02:49 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 08:03:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse.c,v 1.110 2022/01/22 08:02:49 pho Exp $	*/
+/*	$NetBSD: refuse.c,v 1.111 2022/01/22 08:03:32 pho Exp $	*/
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.110 2022/01/22 08:02:49 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.111 2022/01/22 08:03:32 pho Exp $");
 #endif /* !lint */
 
 #include 
@@ -1414,6 +1414,20 @@ fuse_unmount_compat22(const char *mp)
 	return;
 }
 
+void
+fuse_lib_help(struct fuse_args *args 

CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:03:32 UTC 2022

Modified Files:
src/lib/librefuse: fuse.h fuse_lowlevel.h refuse.c

Log Message:
Implement some missing functions that are part of the API


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/librefuse/fuse.h
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/fuse_lowlevel.h
cvs rdiff -u -r1.110 -r1.111 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:02:50 UTC 2022

Modified Files:
src/lib/librefuse: Makefile fuse.h refuse.c
Added Files:
src/lib/librefuse: refuse_compat.c

Log Message:
Correct the wrong prototype of fuse_daemonize(3) while retaining ABI 
compatibility


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/librefuse/Makefile
cvs rdiff -u -r1.30 -r1.31 src/lib/librefuse/fuse.h
cvs rdiff -u -r1.109 -r1.110 src/lib/librefuse/refuse.c
cvs rdiff -u -r0 -r1.1 src/lib/librefuse/refuse_compat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/Makefile
diff -u src/lib/librefuse/Makefile:1.15 src/lib/librefuse/Makefile:1.16
--- src/lib/librefuse/Makefile:1.15	Sat Jan 22 07:58:32 2022
+++ src/lib/librefuse/Makefile	Sat Jan 22 08:02:49 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.15 2022/01/22 07:58:32 pho Exp $
+# $NetBSD: Makefile,v 1.16 2022/01/22 08:02:49 pho Exp $
 
 USE_FORT?=	yes	# data driven bugs?
 
@@ -12,7 +12,7 @@ FUSE_OPT_DEBUG_FLAGS=	-g -DFUSE_OPT_DEBU
 
 CFLAGS+=	${FUSE_OPT_DEBUG_FLAGS}
 CPPFLAGS+=	-I${.CURDIR}
-SRCS=		refuse.c refuse_log.c refuse_lowlevel.c
+SRCS=		refuse.c refuse_compat.c refuse_log.c refuse_lowlevel.c
 SRCS+=		refuse_opt.c refuse_signals.c
 MAN=		refuse.3
 WARNS?=		6

Index: src/lib/librefuse/fuse.h
diff -u src/lib/librefuse/fuse.h:1.30 src/lib/librefuse/fuse.h:1.31
--- src/lib/librefuse/fuse.h:1.30	Sat Jan 22 08:01:50 2022
+++ src/lib/librefuse/fuse.h	Sat Jan 22 08:02:49 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.30 2022/01/22 08:01:50 pho Exp $ */
+/* $NetBSD: fuse.h,v 1.31 2022/01/22 08:02:49 pho Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -201,13 +201,20 @@ int fuse_invalidate_path(struct fuse *fu
 int fuse_mount(struct fuse *, const char *);
 void fuse_unmount(struct fuse *);
 
-int fuse_daemonize(struct fuse *);
-
 int fuse_main_real(int, char **, const struct fuse_operations *, size_t, void *);
+/* Functions that have existed since the beginning and have never
+ * changed between API versions. */
 int fuse_loop(struct fuse *);
 struct fuse_context *fuse_get_context(void);
 void fuse_exit(struct fuse *);
 void fuse_destroy(struct fuse *);
+
+/* Daemonize the calling process. Appeared on FUSE 2.6.
+ *
+ * NOTE: This function used to have a wrong prototype in librefuse at
+ * the time when FUSE_H_ < 20211204. */
+int fuse_daemonize(int foreground) __RENAME(fuse_daemonize_rev1);
+
 int fuse_version(void);
 
 #if FUSE_USE_VERSION == 22

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.109 src/lib/librefuse/refuse.c:1.110
--- src/lib/librefuse/refuse.c:1.109	Sat Jan 22 08:01:12 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 08:02:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse.c,v 1.109 2022/01/22 08:01:12 pho Exp $	*/
+/*	$NetBSD: refuse.c,v 1.110 2022/01/22 08:02:49 pho Exp $	*/
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.109 2022/01/22 08:01:12 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.110 2022/01/22 08:02:49 pho Exp $");
 #endif /* !lint */
 
 #include 
@@ -1248,9 +1248,23 @@ int fuse_mount(struct fuse *fuse, const 
 	return 0;
 }
 
-int fuse_daemonize(struct fuse *fuse)
+int fuse_daemonize(int foreground)
 {
-	return puffs_daemon(fuse->pu, 0, 0);
+	/* There is an impedance mismatch here: FUSE wants to
+	 * daemonize the process without any contexts but puffs wants
+	 * one. */
+	struct fuse *fuse = fuse_get_context()->fuse;
+
+	if (!fuse)
+		/* FUSE would probably allow this, but we cannot. */
+		errx(EXIT_FAILURE,
+		 "%s: librefuse doesn't allow calling"
+		 " this function before fuse_new().", __func__);
+
+	if (!foreground)
+		return puffs_daemon(fuse->pu, 0, 0);
+
+	return 0;
 }
 
 /* ARGSUSED1 */

Added files:

Index: src/lib/librefuse/refuse_compat.c
diff -u /dev/null src/lib/librefuse/refuse_compat.c:1.1
--- /dev/null	Sat Jan 22 08:02:50 2022
+++ src/lib/librefuse/refuse_compat.c	Sat Jan 22 08:02:49 2022
@@ -0,0 +1,60 @@
+/* $NetBSD: refuse_compat.c,v 1.1 2022/01/22 08:02:49 pho Exp $ */
+
+/*
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote
+ *products derived from this software without specific prior written
+ *

CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:02:50 UTC 2022

Modified Files:
src/lib/librefuse: Makefile fuse.h refuse.c
Added Files:
src/lib/librefuse: refuse_compat.c

Log Message:
Correct the wrong prototype of fuse_daemonize(3) while retaining ABI 
compatibility


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/librefuse/Makefile
cvs rdiff -u -r1.30 -r1.31 src/lib/librefuse/fuse.h
cvs rdiff -u -r1.109 -r1.110 src/lib/librefuse/refuse.c
cvs rdiff -u -r0 -r1.1 src/lib/librefuse/refuse_compat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:01:51 UTC 2022

Modified Files:
src/lib/librefuse: fuse.h fuse_opt.h

Log Message:
Cosmetic changes


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/librefuse/fuse.h
cvs rdiff -u -r1.9 -r1.10 src/lib/librefuse/fuse_opt.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/librefuse/fuse.h
diff -u src/lib/librefuse/fuse.h:1.29 src/lib/librefuse/fuse.h:1.30
--- src/lib/librefuse/fuse.h:1.29	Sat Jan 22 08:01:12 2022
+++ src/lib/librefuse/fuse.h	Sat Jan 22 08:01:50 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.29 2022/01/22 08:01:12 pho Exp $ */
+/* $NetBSD: fuse.h,v 1.30 2022/01/22 08:01:50 pho Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -30,6 +30,7 @@
 #ifndef FUSE_H_
 #define FUSE_H_	20211204
 
+#include 
 #include 
 #include 
 #include 
@@ -227,6 +228,4 @@ void fuse_unmount_compat22(const char *)
 }
 #endif
 
-#include 
-
 #endif

Index: src/lib/librefuse/fuse_opt.h
diff -u src/lib/librefuse/fuse_opt.h:1.9 src/lib/librefuse/fuse_opt.h:1.10
--- src/lib/librefuse/fuse_opt.h:1.9	Wed Dec  1 14:17:50 2021
+++ src/lib/librefuse/fuse_opt.h	Sat Jan 22 08:01:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fuse_opt.h,v 1.9 2021/12/01 14:17:50 pho Exp $	*/
+/*	$NetBSD: fuse_opt.h,v 1.10 2022/01/22 08:01:50 pho Exp $	*/
 
 /*
  * Copyright (c) 2007 Alistair Crooks.  All rights reserved.
@@ -35,7 +35,7 @@
 
 #ifdef __cplusplus
 extern "C" {
-#endif  
+#endif
 
 enum {
 	FUSE_OPT_KEY_OPT = -1,
@@ -44,6 +44,8 @@ enum {
 	FUSE_OPT_KEY_DISCARD = -4
 };
 
+struct fuse_args;
+
 struct fuse_opt {
 	const char	*templ;
 	int32_t		offset;
@@ -68,6 +70,6 @@ int fuse_opt_match(const struct fuse_opt
 
 #ifdef __cplusplus
 }
-#endif 
+#endif
 
 #endif /* _FUSE_OPT_H_ */



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:01:51 UTC 2022

Modified Files:
src/lib/librefuse: fuse.h fuse_opt.h

Log Message:
Cosmetic changes


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/librefuse/fuse.h
cvs rdiff -u -r1.9 -r1.10 src/lib/librefuse/fuse_opt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:01:12 UTC 2022

Modified Files:
src/lib/librefuse: fuse.h fuse_internal.h refuse.c

Log Message:
Change the way how FUSE_*_VERSION are handled

* FUSE_MAKE_VERSION(maj, min) now generates a 3-digits number if the
  version is higher than 3.9. This is needed to support FUSE 3.10 API.

* FUSE_{MAJOR,MINOR}_VERSION no longer have a fixed value but are
  derived from FUSE_USE_VERSION specified by the user code. This is
  needed to support more FUSE filesystems in the wild.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/librefuse/fuse.h
cvs rdiff -u -r1.2 -r1.3 src/lib/librefuse/fuse_internal.h
cvs rdiff -u -r1.108 -r1.109 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/fuse.h
diff -u src/lib/librefuse/fuse.h:1.28 src/lib/librefuse/fuse.h:1.29
--- src/lib/librefuse/fuse.h:1.28	Sat Jan 22 07:57:30 2022
+++ src/lib/librefuse/fuse.h	Sat Jan 22 08:01:12 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.28 2022/01/22 07:57:30 pho Exp $ */
+/* $NetBSD: fuse.h,v 1.29 2022/01/22 08:01:12 pho Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -40,24 +40,52 @@
 #include 
 #include 
 
-/* The latest version of FUSE API currently provided by refuse. */
-#define FUSE_MAJOR_VERSION	2
-#define FUSE_MINOR_VERSION	6
+/* This used to be (maj) * 10 + (min) until FUSE 3.10, and then
+ * changed to (maj) * 100 + (min). We can't just use the "newer"
+ * definition because filesystems in the wild still use the older one
+ * in their FUSE_USE_VERSION request. */
+#define FUSE_MAKE_VERSION(maj, min)	\
+	(((maj) > 3 || ((maj) == 3 && (min) >= 10))			\
+	? (maj) * 100 + (min)		\
+	: (maj) *  10 + (min))
+
+/* The latest version of FUSE API currently provided by ReFUSE. This
+ * is an implementation detail. User code should not rely on this
+ * constant. */
+#define _REFUSE_MAJOR_VERSION_	2
+#define _REFUSE_MINOR_VERSION_	6
 
-#define FUSE_MAKE_VERSION(maj, min)	((maj) * 10 + (min))
-#define FUSE_VERSION	FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
+#define _REFUSE_VERSION_	FUSE_MAKE_VERSION(_REFUSE_MAJOR_VERSION_, _REFUSE_MINOR_VERSION_)
 
 /* FUSE_USE_VERSION is expected to be defined by user code to
  * determine the API to be used. Although defining this macro is
  * mandatory in the original FUSE implementation, refuse hasn't
  * required this so we only emit a warning if it's undefined. */
 #if defined(FUSE_USE_VERSION)
-#	if FUSE_USE_VERSION > FUSE_VERSION
+#	if FUSE_USE_VERSION > _REFUSE_VERSION_
 #		warning "The requested API version is higher than the latest one supported by refuse."
+#	elif FUSE_USE_VERSION < 11
+#		warning "The requested API version is lower than the oldest one supported by refuse."
 #	endif
 #else
-#	warning "User code including  should define FUSE_USE_VERSION before including this header. Defaulting to the latest version."
-#	define FUSE_USE_VERSION	FUSE_VERSION
+#	if !defined(_REFUSE_IMPLEMENTATION_)
+#		warning "User code including  should define FUSE_USE_VERSION before including this header. Defaulting to the latest version."
+#		define FUSE_USE_VERSION	_REFUSE_VERSION_
+#	endif
+#endif
+
+/* FUSE_VERSION is supposed to be the latest version of FUSE API
+ * supported by the library. However, due to the way how original FUSE
+ * is implemented, some filesystems set FUSE_USE_VERSION to some old
+ * one and then expect the actual API version exposed by the library
+ * to be something newer if FUSE_VERSION is higher than that. ReFUSE
+ * doesn't work that way, so this has to be always identical to
+ * FUSE_USE_VERSION.
+ */
+#if defined(FUSE_USE_VERSION)
+#	define FUSE_VERSION		FUSE_USE_VERSION
+#	define FUSE_MAJOR_VERSION	(FUSE_VERSION / 10)
+#	define FUSE_MINOR_VERSION	(FUSE_VERSION % 10)
 #endif
 
 #ifdef __cplusplus

Index: src/lib/librefuse/fuse_internal.h
diff -u src/lib/librefuse/fuse_internal.h:1.2 src/lib/librefuse/fuse_internal.h:1.3
--- src/lib/librefuse/fuse_internal.h:1.2	Sat Jan 22 07:53:06 2022
+++ src/lib/librefuse/fuse_internal.h	Sat Jan 22 08:01:12 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse_internal.h,v 1.2 2022/01/22 07:53:06 pho Exp $ */
+/* $NetBSD: fuse_internal.h,v 1.3 2022/01/22 08:01:12 pho Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -32,9 +32,9 @@
 #define FUSE_INTERNAL_H
 
 /* We emit a compiler warning for anyone including  without
- * defining FUSE_USE_VERSION. Define it here, or otherwise we'll be
+ * defining FUSE_USE_VERSION. Exempt ourselves here, or we'll be
  * warned too. */
-#define FUSE_USE_VERSION	FUSE_VERSION
+#define _REFUSE_IMPLEMENTATION_
 
 #include 
 #include 

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.108 src/lib/librefuse/refuse.c:1.109
--- src/lib/librefuse/refuse.c:1.108	Sat Jan 22 08:00:17 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 

CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:01:12 UTC 2022

Modified Files:
src/lib/librefuse: fuse.h fuse_internal.h refuse.c

Log Message:
Change the way how FUSE_*_VERSION are handled

* FUSE_MAKE_VERSION(maj, min) now generates a 3-digits number if the
  version is higher than 3.9. This is needed to support FUSE 3.10 API.

* FUSE_{MAJOR,MINOR}_VERSION no longer have a fixed value but are
  derived from FUSE_USE_VERSION specified by the user code. This is
  needed to support more FUSE filesystems in the wild.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/librefuse/fuse.h
cvs rdiff -u -r1.2 -r1.3 src/lib/librefuse/fuse_internal.h
cvs rdiff -u -r1.108 -r1.109 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:00:17 UTC 2022

Modified Files:
src/lib/librefuse: refuse.c

Log Message:
Implement a dummy pathconf() which always returns EINVAL


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.107 src/lib/librefuse/refuse.c:1.108
--- src/lib/librefuse/refuse.c:1.107	Sat Jan 22 07:59:33 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 08:00:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse.c,v 1.107 2022/01/22 07:59:33 pho Exp $	*/
+/*	$NetBSD: refuse.c,v 1.108 2022/01/22 08:00:17 pho Exp $	*/
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.107 2022/01/22 07:59:33 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.108 2022/01/22 08:00:17 pho Exp $");
 #endif /* !lint */
 
 /* We emit a compiler warning for anyone including  without
@@ -855,6 +855,19 @@ puffs_fuse_node_setattr(struct puffs_use
 	return fuse_setattr(fuse, pn, path, va);
 }
 
+static int
+puffs_fuse_node_pathconf(struct puffs_usermount *pu, void *opc,
+	int name, __register_t *retval)
+{
+	/* Returning EINVAL for pathconf(2) means that this filesystem
+	 * does not support an association of the given name with the
+	 * file. This is necessary because the default error code
+	 * returned by the puffs kernel module (ENOTSUPP) is not
+	 * suitable for an errno from pathconf(2), and "ls -l"
+	 * complains about it. */
+	return EINVAL;
+}
+
 /* ARGSUSED2 */
 static int
 puffs_fuse_node_open(struct puffs_usermount *pu, void *opc, int mode,
@@ -1296,6 +1309,7 @@ fuse_new(struct fuse_args *args,
 PUFFSOP_SET(pops, puffs_fuse, node, lookup);
 PUFFSOP_SET(pops, puffs_fuse, node, getattr);
 PUFFSOP_SET(pops, puffs_fuse, node, setattr);
+	PUFFSOP_SET(pops, puffs_fuse, node, pathconf);
 PUFFSOP_SET(pops, puffs_fuse, node, readdir);
 PUFFSOP_SET(pops, puffs_fuse, node, readlink);
 PUFFSOP_SET(pops, puffs_fuse, node, mknod);



CVS commit: src/lib/librefuse

2022-01-22 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 08:00:17 UTC 2022

Modified Files:
src/lib/librefuse: refuse.c

Log Message:
Implement a dummy pathconf() which always returns EINVAL


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-21 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 07:59:33 UTC 2022

Modified Files:
src/lib/librefuse: refuse.c

Log Message:
Do not call fuse_operations.getattr() before initializing filesystem


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.106 src/lib/librefuse/refuse.c:1.107
--- src/lib/librefuse/refuse.c:1.106	Sat Jan 22 07:58:32 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 07:59:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse.c,v 1.106 2022/01/22 07:58:32 pho Exp $	*/
+/*	$NetBSD: refuse.c,v 1.107 2022/01/22 07:59:33 pho Exp $	*/
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.106 2022/01/22 07:58:32 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.107 2022/01/22 07:59:33 pho Exp $");
 #endif /* !lint */
 
 /* We emit a compiler warning for anyone including  without
@@ -1207,7 +1207,6 @@ int fuse_mount(struct fuse *fuse, const 
 	struct puffs_pathobj	*po_root;
 	struct puffs_node	*pn_root;
 	struct refusenode	*rn_root;
-	struct stat		 st;
 	struct puffs_statvfs	 svfsb;
 
 	pn_root = newrn(fuse->pu);
@@ -1225,10 +1224,11 @@ int fuse_mount(struct fuse *fuse, const 
 	puffs_vattr_null(_root->pn_va);
 	pn_root->pn_va.va_type = VDIR;
 	pn_root->pn_va.va_mode = 0755;
-	if (fuse->op.getattr)
-		if (fuse->op.getattr(po_root->po_path, ) == 0)
-			puffs_stat2vattr(_root->pn_va, );
-	assert(pn_root->pn_va.va_type == VDIR);
+	/* It might be tempting to call op.getattr("/") here to
+	 * populate pn_root->pa_va, but that would mean invoking an
+	 * operation callback without initializing the filesystem. We
+	 * cannot call op.init() either, because that is supposed to
+	 * be called right before entering the main loop. */
 
 	puffs_set_prepost(fuse->pu, set_fuse_context_pid, NULL);
 



CVS commit: src/lib/librefuse

2022-01-21 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 07:59:33 UTC 2022

Modified Files:
src/lib/librefuse: refuse.c

Log Message:
Do not call fuse_operations.getattr() before initializing filesystem


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-21 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 07:58:32 UTC 2022

Modified Files:
src/lib/librefuse: Makefile TODO refuse.c refuse_opt.c

Log Message:
Increase the warning level to spot more mistakes


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/librefuse/Makefile
cvs rdiff -u -r1.6 -r1.7 src/lib/librefuse/TODO
cvs rdiff -u -r1.105 -r1.106 src/lib/librefuse/refuse.c
cvs rdiff -u -r1.22 -r1.23 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/Makefile
diff -u src/lib/librefuse/Makefile:1.14 src/lib/librefuse/Makefile:1.15
--- src/lib/librefuse/Makefile:1.14	Sat Jan 22 07:53:06 2022
+++ src/lib/librefuse/Makefile	Sat Jan 22 07:58:32 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.14 2022/01/22 07:53:06 pho Exp $
+# $NetBSD: Makefile,v 1.15 2022/01/22 07:58:32 pho Exp $
 
 USE_FORT?=	yes	# data driven bugs?
 
@@ -15,7 +15,7 @@ CPPFLAGS+=	-I${.CURDIR}
 SRCS=		refuse.c refuse_log.c refuse_lowlevel.c
 SRCS+=		refuse_opt.c refuse_signals.c
 MAN=		refuse.3
-WARNS?=		5
+WARNS?=		6
 INCS=   fuse.h fuse_opt.h fuse_log.h fuse_lowlevel.h
 INCSDIR=/usr/include
 

Index: src/lib/librefuse/TODO
diff -u src/lib/librefuse/TODO:1.6 src/lib/librefuse/TODO:1.7
--- src/lib/librefuse/TODO:1.6	Sat Jan 22 07:56:16 2022
+++ src/lib/librefuse/TODO	Sat Jan 22 07:58:32 2022
@@ -1,4 +1,4 @@
-	$NetBSD: TODO,v 1.6 2022/01/22 07:56:16 pho Exp $
+	$NetBSD: TODO,v 1.7 2022/01/22 07:58:32 pho Exp $
 
 To Do
 =
@@ -18,7 +18,7 @@ Done
 
 statvfs
 sync
-WARNS=4
+WARNS=6
 address lint
 special directory handling in open()
 Finish off manual page

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.105 src/lib/librefuse/refuse.c:1.106
--- src/lib/librefuse/refuse.c:1.105	Sat Jan 22 07:57:30 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 07:58:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse.c,v 1.105 2022/01/22 07:57:30 pho Exp $	*/
+/*	$NetBSD: refuse.c,v 1.106 2022/01/22 07:58:32 pho Exp $	*/
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.105 2022/01/22 07:57:30 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.106 2022/01/22 07:58:32 pho Exp $");
 #endif /* !lint */
 
 /* We emit a compiler warning for anyone including  without
@@ -301,7 +301,7 @@ puffs_fuse_fill_dir(void *buf, const cha
 		dtype = DT_UNKNOWN;
 		dino = fakeino++;
 	} else {
-		dtype = puffs_vtype2dt(puffs_mode2vt(stbuf->st_mode));
+		dtype = (uint8_t)puffs_vtype2dt(puffs_mode2vt(stbuf->st_mode));
 		dino = stbuf->st_ino;
 
 		/*
@@ -571,7 +571,7 @@ puffs_fuse_node_readlink(struct puffs_us
 		if (!p)
 			return EINVAL;
 
-		*linklen = p - linkname;
+		*linklen = (size_t)(p - linkname);
 	}
 
 	return -ret;
@@ -948,9 +948,9 @@ puffs_fuse_node_read(struct puffs_usermo
 	set_fuse_context_uid_gid(pcr);
 
 	maxread = *resid;
-	if (maxread > pn->pn_va.va_size - offset) {
+	if (maxread > (size_t)((off_t)pn->pn_va.va_size - offset)) {
 		/*LINTED*/
-		maxread = pn->pn_va.va_size - offset;
+		maxread = (size_t)((off_t)pn->pn_va.va_size - offset);
 	}
 	if (maxread == 0)
 		return 0;
@@ -959,7 +959,7 @@ puffs_fuse_node_read(struct puffs_usermo
 	>file_info);
 
 	if (ret > 0) {
-		*resid -= ret;
+		*resid -= (size_t)ret;
 		ret = 0;
 	}
 
@@ -987,15 +987,15 @@ puffs_fuse_node_write(struct puffs_userm
 	set_fuse_context_uid_gid(pcr);
 
 	if (ioflag & PUFFS_IO_APPEND)
-		offset = pn->pn_va.va_size;
+		offset = (off_t)pn->pn_va.va_size;
 
 	ret = (*fuse->op.write)(path, (char *)buf, *resid, offset,
 	>file_info);
 
 	if (ret >= 0) {
 		if ((uint64_t)(offset + ret) > pn->pn_va.va_size)
-			pn->pn_va.va_size = offset + ret;
-		*resid -= ret;
+			pn->pn_va.va_size = (u_quad_t)(offset + ret);
+		*resid -= (size_t)ret;
 		ret = (*resid == 0) ? 0 : ENOSPC;
 	} else {
 		ret = -ret;
@@ -1062,7 +1062,7 @@ puffs_fuse_node_readdir(struct puffs_use
 			break;
 
 		memcpy(dent, fromdent, _DIRENT_SIZE(fromdent));
-		*readoff += _DIRENT_SIZE(fromdent);
+		*readoff += (off_t)_DIRENT_SIZE(fromdent);
 		*reslen -= _DIRENT_SIZE(fromdent);
 
 		dent = _DIRENT_NEXT(dent);
@@ -1255,7 +1255,7 @@ fuse_new(struct fuse_args *args,
 	struct fuse_context	*fusectx;
 	struct puffs_ops	*pops;
 	struct fuse		*fuse;
-	int			puffs_flags;
+	uint32_t		puffs_flags;
 
 	/* parse refuse options */
 	if (fuse_opt_parse(args, , refuse_opts, NULL) == -1)

Index: src/lib/librefuse/refuse_opt.c
diff -u src/lib/librefuse/refuse_opt.c:1.22 src/lib/librefuse/refuse_opt.c:1.23
--- src/lib/librefuse/refuse_opt.c:1.22	Sat Dec  4 06:42:39 2021
+++ src/lib/librefuse/refuse_opt.c	Sat Jan 22 07:58:32 2022
@@ -1,4 +1,4 @@
-/* 	$NetBSD: refuse_opt.c,v 1.22 2021/12/04 06:42:39 pho Exp $	*/
+/* 	$NetBSD: refuse_opt.c,v 1.23 2022/01/22 07:58:32 pho Exp $	*/
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -60,7 

CVS commit: src/lib/librefuse

2022-01-21 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 07:58:32 UTC 2022

Modified Files:
src/lib/librefuse: Makefile TODO refuse.c refuse_opt.c

Log Message:
Increase the warning level to spot more mistakes


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/librefuse/Makefile
cvs rdiff -u -r1.6 -r1.7 src/lib/librefuse/TODO
cvs rdiff -u -r1.105 -r1.106 src/lib/librefuse/refuse.c
cvs rdiff -u -r1.22 -r1.23 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2022-01-21 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 07:39:22 UTC 2022

Added Files:
src/lib/librefuse: fuse_log.h refuse_log.c

Log Message:
lib/librefuse: Implement logging API appeared on FUSE 3.7


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/librefuse/fuse_log.h \
src/lib/librefuse/refuse_log.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/lib/librefuse/fuse_log.h
diff -u /dev/null src/lib/librefuse/fuse_log.h:1.1
--- /dev/null	Sat Jan 22 07:39:22 2022
+++ src/lib/librefuse/fuse_log.h	Sat Jan 22 07:39:22 2022
@@ -0,0 +1,63 @@
+/* $NetBSD: fuse_log.h,v 1.1 2022/01/22 07:39:22 pho Exp $ */
+
+/*
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote
+ *products derived from this software without specific prior written
+ *permission.
+ *
+ * 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 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 !defined(_FUSE_LOG_H_)
+#define _FUSE_LOG_H_
+
+/* FUSE logging API, appeared on FUSE 3.7. */
+
+#include 
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum fuse_log_level {
+	FUSE_LOG_EMERG,
+	FUSE_LOG_ALERT,
+	FUSE_LOG_CRIT,
+	FUSE_LOG_ERR,
+	FUSE_LOG_WARNING,
+	FUSE_LOG_NOTICE,
+	FUSE_LOG_INFO,
+	FUSE_LOG_DEBUG
+};
+
+typedef void (*fuse_log_func_t)(enum fuse_log_level level, const char *fmt, va_list ap);
+
+void fuse_set_log_func(fuse_log_func_t func);
+void fuse_log(enum fuse_log_level level, const char *fmt, ...) __printflike(2, 3);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: src/lib/librefuse/refuse_log.c
diff -u /dev/null src/lib/librefuse/refuse_log.c:1.1
--- /dev/null	Sat Jan 22 07:39:22 2022
+++ src/lib/librefuse/refuse_log.c	Sat Jan 22 07:39:22 2022
@@ -0,0 +1,100 @@
+/* $NetBSD: refuse_log.c,v 1.1 2022/01/22 07:39:22 pho Exp $ */
+
+/*
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote
+ *products derived from this software without specific prior written
+ *permission.
+ *
+ * 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 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.
+ */
+
+#include 
+#if !defined(lint)
+__RCSID("$NetBSD: refuse_log.c,v 1.1 2022/01/22 07:39:22 pho Exp $");
+#endif /* !lint */
+
+#include 
+#include 
+#if defined(MULTITHREADED_REFUSE)
+#	include 
+#endif
+#include 
+
+static void
+default_log_func(enum fuse_log_level level __attribute__((__unused__)),
+ const char 

CVS commit: src/lib/librefuse

2022-01-21 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Sat Jan 22 07:39:22 UTC 2022

Added Files:
src/lib/librefuse: fuse_log.h refuse_log.c

Log Message:
lib/librefuse: Implement logging API appeared on FUSE 3.7


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/librefuse/fuse_log.h \
src/lib/librefuse/refuse_log.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2021-12-01 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Wed Dec  1 14:17:51 UTC 2021

Modified Files:
src/lib/librefuse: fuse_opt.h refuse_opt.c

Log Message:
Revert my previous change to struct fuse_opt

I should have thought twice before commiting it. Of course changing
the layout of a struct breaks ABI compatibility. Change the offset
back to fixed 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/librefuse/fuse_opt.h
cvs rdiff -u -r1.20 -r1.21 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/fuse_opt.h
diff -u src/lib/librefuse/fuse_opt.h:1.8 src/lib/librefuse/fuse_opt.h:1.9
--- src/lib/librefuse/fuse_opt.h:1.8	Wed Dec  1 13:51:33 2021
+++ src/lib/librefuse/fuse_opt.h	Wed Dec  1 14:17:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fuse_opt.h,v 1.8 2021/12/01 13:51:33 pho Exp $	*/
+/*	$NetBSD: fuse_opt.h,v 1.9 2021/12/01 14:17:50 pho Exp $	*/
 
 /*
  * Copyright (c) 2007 Alistair Crooks.  All rights reserved.
@@ -46,11 +46,11 @@ enum {
 
 struct fuse_opt {
 	const char	*templ;
-	unsigned long	offset;
-	int		value;
+	int32_t		offset;
+	int32_t		value;
 };
 
-#define FUSE_OPT_KEY(templ, key) { templ, -1U, key }
+#define FUSE_OPT_KEY(templ, key) { templ, -1, key }
 #define FUSE_OPT_END { .templ = NULL }
 
 typedef int (*fuse_opt_proc_t)(void *, const char *, int, struct fuse_args *);

Index: src/lib/librefuse/refuse_opt.c
diff -u src/lib/librefuse/refuse_opt.c:1.20 src/lib/librefuse/refuse_opt.c:1.21
--- src/lib/librefuse/refuse_opt.c:1.20	Wed Dec  1 13:51:33 2021
+++ src/lib/librefuse/refuse_opt.c	Wed Dec  1 14:17:50 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: refuse_opt.c,v 1.20 2021/12/01 13:51:33 pho Exp $	*/
+/* 	$NetBSD: refuse_opt.c,v 1.21 2021/12/01 14:17:50 pho Exp $	*/
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -286,7 +286,7 @@ parse_matched_arg(const char* arg, struc
 		const struct fuse_opt* opt, int sep_idx, void* data,
 		fuse_opt_proc_t proc, bool is_opt)
 {
-	if (opt->offset == -1U) {
+	if (opt->offset == -1) {
 		/* The option description does not want any variables to be
 		 * updated.*/
 		if (call_proc(proc, data, arg, opt->value, outargs, is_opt) == -1)



CVS commit: src/lib/librefuse

2021-12-01 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Wed Dec  1 14:17:51 UTC 2021

Modified Files:
src/lib/librefuse: fuse_opt.h refuse_opt.c

Log Message:
Revert my previous change to struct fuse_opt

I should have thought twice before commiting it. Of course changing
the layout of a struct breaks ABI compatibility. Change the offset
back to fixed 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/librefuse/fuse_opt.h
cvs rdiff -u -r1.20 -r1.21 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2021-12-01 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Wed Dec  1 13:51:33 UTC 2021

Modified Files:
src/lib/librefuse: fuse_opt.h refuse_opt.c

Log Message:
Use correct types for the fields of struct fuse_opt

This change shouldn't make any behavioral differences in reality, but
compilers these days dislike converting -1U to int32_t implicitly,
which is indeed understandable.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/librefuse/fuse_opt.h
cvs rdiff -u -r1.19 -r1.20 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/fuse_opt.h
diff -u src/lib/librefuse/fuse_opt.h:1.7 src/lib/librefuse/fuse_opt.h:1.8
--- src/lib/librefuse/fuse_opt.h:1.7	Mon Nov 14 17:19:29 2016
+++ src/lib/librefuse/fuse_opt.h	Wed Dec  1 13:51:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fuse_opt.h,v 1.7 2016/11/14 17:19:29 pho Exp $	*/
+/*	$NetBSD: fuse_opt.h,v 1.8 2021/12/01 13:51:33 pho Exp $	*/
 
 /*
  * Copyright (c) 2007 Alistair Crooks.  All rights reserved.
@@ -46,8 +46,8 @@ enum {
 
 struct fuse_opt {
 	const char	*templ;
-	int32_t		offset;
-	int32_t		value;
+	unsigned long	offset;
+	int		value;
 };
 
 #define FUSE_OPT_KEY(templ, key) { templ, -1U, key }

Index: src/lib/librefuse/refuse_opt.c
diff -u src/lib/librefuse/refuse_opt.c:1.19 src/lib/librefuse/refuse_opt.c:1.20
--- src/lib/librefuse/refuse_opt.c:1.19	Sat Oct 30 09:06:34 2021
+++ src/lib/librefuse/refuse_opt.c	Wed Dec  1 13:51:33 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: refuse_opt.c,v 1.19 2021/10/30 09:06:34 nia Exp $	*/
+/* 	$NetBSD: refuse_opt.c,v 1.20 2021/12/01 13:51:33 pho Exp $	*/
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -286,7 +286,7 @@ parse_matched_arg(const char* arg, struc
 		const struct fuse_opt* opt, int sep_idx, void* data,
 		fuse_opt_proc_t proc, bool is_opt)
 {
-	if (opt->offset == -1) {
+	if (opt->offset == -1U) {
 		/* The option description does not want any variables to be
 		 * updated.*/
 		if (call_proc(proc, data, arg, opt->value, outargs, is_opt) == -1)



CVS commit: src/lib/librefuse

2021-12-01 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Wed Dec  1 13:51:33 UTC 2021

Modified Files:
src/lib/librefuse: fuse_opt.h refuse_opt.c

Log Message:
Use correct types for the fields of struct fuse_opt

This change shouldn't make any behavioral differences in reality, but
compilers these days dislike converting -1U to int32_t implicitly,
which is indeed understandable.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/librefuse/fuse_opt.h
cvs rdiff -u -r1.19 -r1.20 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2021-11-30 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Tue Nov 30 12:13:12 UTC 2021

Modified Files:
src/lib/librefuse: refuse.c

Log Message:
Move the call of fuse_operations::init() from fuse_new() to fuse_loop()

Prior to this change we were calling init() before daemonizing the
process. Some filesystems call chdir(2) in init() but fuse_daemonize()
call chdir("/"), which breaks assumptions about the state of the
process.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.101 src/lib/librefuse/refuse.c:1.102
--- src/lib/librefuse/refuse.c:1.101	Mon Sep 23 12:00:57 2019
+++ src/lib/librefuse/refuse.c	Tue Nov 30 12:13:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: refuse.c,v 1.101 2019/09/23 12:00:57 christos Exp $	*/
+/*	$NetBSD: refuse.c,v 1.102 2021/11/30 12:13:12 pho Exp $	*/
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.101 2019/09/23 12:00:57 christos Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.102 2021/11/30 12:13:12 pho Exp $");
 #endif /* !lint */
 
 #include 
@@ -1276,9 +1276,6 @@ fuse_new(struct fuse_args *args,
 	fusectx->pid = 0;
 	fusectx->private_data = userdata;
 
-	if (fuse->op.init != NULL)
-		fusectx->private_data = fuse->op.init(NULL); /* XXX */
-
 	/* initialise the puffs operations structure */
 PUFFSOP_INIT(pops);
 
@@ -1328,6 +1325,18 @@ fuse_new(struct fuse_args *args,
 int
 fuse_loop(struct fuse *fuse)
 {
+	if (fuse->op.init != NULL) {
+		struct fuse_context *fusectx = fuse_get_context();
+
+		/* XXX: prototype incompatible with FUSE: a secondary argument
+		 * of struct fuse_config* needs to be passed.
+		 *
+		 * XXX: Our struct fuse_conn_info is not fully compatible with
+		 * the FUSE one.
+		 */
+		fusectx->private_data = fuse->op.init(NULL);
+	}
+
 	return puffs_mainloop(fuse->pu);
 }
 



CVS commit: src/lib/librefuse

2021-11-30 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Tue Nov 30 12:13:12 UTC 2021

Modified Files:
src/lib/librefuse: refuse.c

Log Message:
Move the call of fuse_operations::init() from fuse_new() to fuse_loop()

Prior to this change we were calling init() before daemonizing the
process. Some filesystems call chdir(2) in init() but fuse_daemonize()
call chdir("/"), which breaks assumptions about the state of the
process.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/lib/librefuse/refuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librefuse

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 09:06:34 UTC 2021

Modified Files:
src/lib/librefuse: refuse_opt.c

Log Message:
refuse(3): Simplify reallocation logic with reallocarr.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/refuse_opt.c
diff -u src/lib/librefuse/refuse_opt.c:1.18 src/lib/librefuse/refuse_opt.c:1.19
--- src/lib/librefuse/refuse_opt.c:1.18	Wed Nov 16 16:11:42 2016
+++ src/lib/librefuse/refuse_opt.c	Sat Oct 30 09:06:34 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: refuse_opt.c,v 1.18 2016/11/16 16:11:42 pho Exp $	*/
+/* 	$NetBSD: refuse_opt.c,v 1.19 2021/10/30 09:06:34 nia Exp $	*/
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -58,13 +58,11 @@ fuse_opt_add_arg(struct fuse_args *args,
 		args->allocated = ap->allocated;
 		(void) free(ap);
 	} else if (args->allocated == args->argc) {
-		void *a;
 		int na = args->allocated + 10;
 
-		if ((a = realloc(args->argv, na * sizeof(*args->argv))) == NULL)
+		if (reallocarr(>argv, na, sizeof(*args->argv)) != 0)
 			return -1;
 
-		args->argv = a;
 		args->allocated = na;
 	}
 	DPRINTF(("%s: arguments passed: [arg:%s]\n", __func__, arg));
@@ -119,22 +117,18 @@ fuse_opt_insert_arg(struct fuse_args *ar
 {
 	int	i;
 	int	na;
-	void   *a;
 
 	DPRINTF(("%s: arguments passed: [pos=%d] [arg=%s]\n",
 	__func__, pos, arg));
 	if (args->argv == NULL) {
 		na = 10;
-		a = malloc(na * sizeof(*args->argv));
 	} else {
 		na = args->allocated + 10;
-		a = realloc(args->argv, na * sizeof(*args->argv));
 	}
-	if (a == NULL) {
+	if (reallocarr(>argv, na, sizeof(*args->argv)) != 0) {
 		warn("fuse_opt_insert_arg");
 		return -1;
 	}
-	args->argv = a;
 	args->allocated = na;
 
 	for (i = args->argc++; i > pos; --i) {



CVS commit: src/lib/librefuse

2021-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 30 09:06:34 UTC 2021

Modified Files:
src/lib/librefuse: refuse_opt.c

Log Message:
refuse(3): Simplify reallocation logic with reallocarr.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.