summaryrefslogtreecommitdiff
path: root/filesystems/fuse-httpfs/patches/patch-aa
blob: 6b25836f82946e9bf1e9ffac386aabba91d41a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
$NetBSD: patch-aa,v 1.2 2022/01/22 18:41:21 pho Exp $

Hunk #0:
    Be explicit about the API version it wants to use.

Hunk #1, #2, #3, #5:
    httpfs performs a weird hack that obtains a reference to the
    directory it is going to be mounted on, and then tries to call
    statvfs(2) and opendir(3) on that directory in respective
    filesystem callbacks. On Linux this can somehow avoid deadlocks it
    seems (possibly due to the way how Linux vfs is implemented?), but
    on NetBSD it can't. Don't try to do that.

Hunk #4:
    Workaround for NetBSD librefuse that had an API incompatible with
    FUSE. Already fixed in HEAD.

--- httpfs.c.orig	2006-08-26 06:29:28.000000000 +0000
+++ httpfs.c
@@ -1,3 +1,5 @@
+#define FUSE_USE_VERSION 25
+
 /*
  * HTTPFS: import a file from a web server to local file system
  * the main use is, to mount an iso on a web server with loop device
@@ -550,6 +552,9 @@ static int httpfs_readlink(const char *p
 
 static int httpfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                          off_t offset, struct fuse_file_info *fi) {
+#if defined(__NetBSD__)
+    filler(buf, httpfs_path + 1, NULL, 0);
+#else
     DIR *dp;
     struct dirent *de;
     (void) offset;
@@ -574,6 +579,7 @@ static int httpfs_readdir(const char *pa
     }
 
     closedir(dp);
+#endif
 
     return 0;
 }
@@ -778,11 +784,15 @@ static int httpfs_statfs(const char *pat
     int res;
     (void) path;
 
+#if defined(__NetBSD__)
+    return -ENOSYS;
+#else
     res = statvfs(".", stbuf);
     if (res == -1)
         return -errno;
 
     return 0;
+#endif
 }
 
 static int httpfs_release(const char *path, struct fuse_file_info *fi) {
@@ -802,7 +812,11 @@ static int httpfs_fsync(const char *path
     return 0;
 }
 
+#if defined(__NetBSD__) && FUSE_H_ < 20211204
+static void *httpfs_init(struct fuse_conn_info *conn) {
+#else
 static void *httpfs_init(void) {
+#endif
     fchdir(targetFd);	/* that's the catch */
     return NULL;
 }
@@ -924,11 +938,15 @@ int main(int argc, char *argv[]) {
 	(void) fprintf(stderr, "%s: %s is not a directory\n", argv0, argv2);
 	return 1;
     }
-    
+
+#if defined(__NetBSD__)
+    targetFd = open("/", 0); /* Unused */
+#else
     if ((targetFd = open(argv2, 0)) == -1) {
 	(void) fprintf(stderr, "%s: open %s failed\n", argv0, argv2);
 	return 1;
     }
+#endif
     
     ri = rindex(file_name, '/');
     if (ri == (char *) 0) {