Debian Codegraph @

USAGE.md

raw symbols SCIP
1 ## HTTPDirFS Usage Guide
2
3 HTTPDirFS is a filesystem that allows you to mount HTTP directories locally
4 using FUSE. This document provides a detailed explanation of all the
5 configuration and usage flags supported by HTTPDirFS.
6
7 ### Command Syntax
8
9 Below is the raw help output displaying all available flags, generated from Git
10 commit SHA
11 [`0855c0a`](https://github.com/fangfufu/httpdirfs/commit/0855c0a46a2fa8f8e2d4d084f51d5d124092d067):
12
13 ```bash
14 usage: httpdirfs [options] URL mountpoint
15
16 FUSE options:
17 -h --help print help
18 -V --version print version
19 -d -o debug enable debug output (implies -f)
20 -f foreground operation
21 -s disable multi-threaded operation
22 -o clone_fd use separate fuse device fd for each thread
23 (may improve performance)
24 -o max_idle_threads the maximum number of idle worker threads
25 allowed (default: -1)
26 -o max_threads the maximum number of worker threads
27 allowed (default: 10)
28 -o kernel_cache cache files in kernel
29 -o [no]auto_cache enable caching based on modification times (off)
30 -o no_rofd_flush disable flushing of read-only fd on close (off)
31 -o umask=M set file permissions (octal)
32 -o fmask=M set file permissions (octal)
33 -o dmask=M set dir permissions (octal)
34 -o uid=N set file owner
35 -o gid=N set file group
36 -o entry_timeout=T cache timeout for names (1.0s)
37 -o negative_timeout=T cache timeout for deleted names (0.0s)
38 -o attr_timeout=T cache timeout for attributes (1.0s)
39 -o ac_attr_timeout=T auto cache timeout for attributes (attr_timeout)
40 -o noforget never forget cached inodes
41 -o remember=T remember cached inodes for T seconds (0s)
42 -o modules=M1[:M2...] names of modules to push onto filesystem stack
43 -o allow_other allow access by all users
44 -o allow_root allow access by root
45 -o auto_unmount auto unmount on process termination
46
47 Options for subdir module:
48 -o subdir=DIR prepend this directory to all paths (mandatory)
49 -o [no]rellinks transform absolute symlinks to relative
50
51 Options for iconv module:
52 -o from_code=CHARSET original encoding of file names (default: UTF-8)
53 -o to_code=CHARSET new encoding of the file names (default: UTF-8)
54
55 general options:
56 --config Specify a configuration file
57 -o opt,[opt...] Mount options
58 -h --help Print help
59 -V --version Print version
60 -f Foreground operation
61 -s Disable multi-threaded operation
62 -d --debug Enable debug output (implies -f)
63
64 HTTPDirFS options:
65 -u --username HTTP authentication username
66 -p --password HTTP authentication password
67 -P --proxy Proxy for libcurl, for more details refer to
68 https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html
69 --proxy-username Username for the proxy
70 --proxy-password Password for the proxy
71 --proxy-cacert Certificate authority for the proxy
72 --proxy-capath Certificate authority directory for the proxy
73 --cache Enable cache (default: off)
74 --cache-location Set a custom cache location
75 (default: "${XDG_CACHE_HOME}/httpdirfs")
76 --cache-clear Delete the cache directory or the custom location
77 specified with `--cache-location`, if the option is
78 seen first. Then exit in either case.
79 --cache-min-size Set minimum file size threshold for caching, in bytes
80 (default: none)
81 --cache-max-size Set maximum file size threshold for caching, in bytes
82 (default: none)
83 --cacert Certificate authority for the server
84 --capath Certificate authority directory for the server
85 --dl-seg-size Set cache download segment size, in MB (default: 8)
86 Note: this setting is ignored if previously
87 cached data is found for the requested file.
88 --http-header Set one or more HTTP headers
89 --max-conns Set maximum number of network connections that
90 libcurl is allowed to make. (default: 6)
91 --refresh-timeout The directories are refreshed after the specified
92 time, in seconds (default: 3600)
93 --retry-wait Set delay in seconds before retrying an HTTP request
94 after encountering an error. (default: 5)
95 --invalid-refresh Try refreshing invalid links when reading a directory.
96 --user-agent Set user agent string (default: "HTTPDirFS-1.3.3")
97 --no-range-check Disable the built-in check for the server's support
98 for HTTP range requests
99 --zero-len-is-dir If a file has a zero length, treat it as a directory
100 --insecure-tls Disable libcurl TLS certificate verification by
101 setting CURLOPT_SSL_VERIFYHOST to 0
102 --external-links Include external (cross-origin) links from
103 directory listings (default: off)
104 --single-file-mode Single file mode - rather than mounting a whole
105 directory, present a single file inside a virtual
106 directory.
107
108 For mounting a Airsonic / Subsonic server:
109 --sonic-username The username for your Airsonic / Subsonic server
110 --sonic-password The password for your Airsonic / Subsonic server
111 --sonic-id3 Enable ID3 mode - this present the server content in
112 Artist/Album/Song layout
113 --sonic-insecure Authenticate against your Airsonic / Subsonic server
114 using the insecure username / hex encoded password
115 scheme
116 ```
117
118 ______________________________________________________________________
119
120 ### General Options
121
122 #### `--config <path>`
123
124 - **Description:** Specify the path to a configuration file containing option
125 key-value pairs. Using a configuration file is a clean alternative to passing
126 multiple flags directly via the command line.
127 - **Example:**
128 `httpdirfs --config /etc/httpdirfs/mount.conf http://example.com/dir /mnt/dir`
129
130 #### `-o opt,[opt...]`
131
132 - **Description:** Pass options directly to the underlying FUSE library or load
133 modules. This is extremely powerful for customizing filesystem behavior,
134 permission maps, performance tweaks, and character encoding.
135
136 **Commonly Used FUSE Options:**
137
138 - `ro`: Mount the filesystem as read-only.
139 - `allow_other`: Allow other users on the system to access the mountpoint. By
140 default, only the mounting user has access.
141 - `allow_root`: Allow the root user to access the mountpoint.
142 - `auto_unmount`: Automatically unmount the filesystem when the mounting
143 process terminates.
144 - `kernel_cache`: Cache files in the kernel to significantly speed up repeated
145 reads.
146 - `umask=M`, `fmask=M`, `dmask=M`: Customize permission masks for files and
147 directories (specified in octal, e.g., `umask=022`).
148 - `uid=N`, `gid=N`: Override the user ID and group ID ownership of all virtual
149 files.
150
151 **Commonly Used Module Options:**
152
153 - `subdir=DIR`: Prepend the specified directory `DIR` to all paths (loads the
154 subdir module).
155 - `rellinks` / `norellinks`: Transform absolute symlinks to relative ones
156 within the subdir module.
157 - `from_code=CHARSET` / `to_code=CHARSET`: Translate character encodings of
158 filenames (e.g., from UTF-8 to ISO-8859-1) (loads the iconv module).
159
160 - **Example:**
161 `httpdirfs -o allow_other,ro,auto_unmount http://example.com/dir /mnt/dir`
162
163 #### `-h, --help`
164
165 - **Description:** Prints a concise summary of the command-line usage and exits.
166
167 #### `-V, --version`
168
169 - **Description:** Prints the current version information of HTTPDirFS and
170 exits.
171
172 #### `-f`
173
174 - **Description:** Runs HTTPDirFS in the foreground. By default, HTTPDirFS
175 daemonizes and runs in the background. Running in the foreground is useful for
176 debugging or when running inside containers (e.g., Docker).
177
178 #### `-s`
179
180 - **Description:** Disables multi-threaded operation. This runs FUSE and network
181 operations in a single thread, which can be useful for debugging concurrency
182 issues.
183
184 #### `-d, --debug`
185
186 - **Description:** Enables verbose debug output. This output includes detailed
187 curl request logs and FUSE kernel-level interaction logs. Note that this flag
188 automatically implies foreground operation (`-f`).
189
190 ______________________________________________________________________
191
192 ### HTTPDirFS Core Options
193
194 #### `-u, --username <string>`
195
196 - **Description:** Sets the HTTP authentication username for servers requiring
197 Basic, Digest, or NTLM authentication.
198 - **Note:** Credentials are automatically scoped to the primary mount server
199 only.
200
201 #### `-p, --password <string>`
202
203 - **Description:** Sets the HTTP authentication password for servers requiring
204 authentication.
205
206 #### `-P, --proxy <url>`
207
208 - **Description:** Set the HTTP proxy server URL (e.g., `http://127.0.0.1:8080`)
209 for all network requests. For more details, refer to the
210 [CURLOPT_PROXY documentation](https://curl.se/libcurl/c/CURLOPT_PROXY.html).
211
212 #### `--proxy-username <string>`
213
214 - **Description:** The username to authenticate against the specified proxy
215 server.
216
217 #### `--proxy-password <string>`
218
219 - **Description:** The password to authenticate against the specified proxy
220 server.
221
222 #### `--proxy-cacert <path>`
223
224 - **Description:** Path to a custom Certificate Authority (CA) bundle file used
225 to verify the TLS certificate of the proxy server.
226
227 #### `--proxy-capath <path>`
228
229 - **Description:** Path to a directory containing CA certificates to verify the
230 TLS certificate of the proxy server.
231
232 #### `--cacert <path>`
233
234 - **Description:** Path to a Certificate Authority (CA) PEM bundle file to
235 verify the SSL certificate of the remote HTTPS directory server.
236
237 #### `--capath <path>`
238
239 - **Description:** Path to a directory containing CA PEM certificates to verify
240 the SSL certificate of the HTTPS directory server.
241
242 #### `--insecure-tls`
243
244 - **Description:** Disables TLS certificate validation of the HTTPS server (sets
245 `CURLOPT_SSL_VERIFYPEER` and `CURLOPT_SSL_VERIFYHOST` to 0). Useful for
246 mounting servers using self-signed certificates in private networks.
247 - **Warning:** Disabling certificate verification exposes connections to
248 potential man-in-the-middle (MitM) attacks.
249
250 ______________________________________________________________________
251
252 ### Cache Settings
253
254 #### `--cache`
255
256 - **Description:** Enables the persistent local cache mode. When cache mode is
257 active, HTTPDirFS caches directory trees and file content segments locally on
258 disk. Subsequent directory reads and file accesses are served from the cache,
259 significantly improving speed and reducing network usage.
260
261 #### `--cache-location <path>`
262
263 - **Description:** Specify a custom directory path where cache data and metadata
264 should be stored.
265 - **Default:** `${XDG_CACHE_HOME}/httpdirfs` (usually resolves to
266 `~/.cache/httpdirfs`).
267
268 #### `--cache-clear`
269
270 - **Description:** Deletes the existing cache directory (or the custom cache
271 path if `--cache-location` is specified before this option) and immediately
272 exits. Highly useful for cleaning up disk space or forcing a full directory
273 recrawl.
274
275 #### `--dl-seg-size <size>`
276
277 - **Description:** Sets the size of individual file cache segments in Megabytes
278 (MB).
279 - **Default:** `8`
280 - **Note:** This setting is ignored for files that already have existing cached
281 segment data on disk.
282
283 #### `--cache-min-size <bytes>`
284
285 - **Description:** Sets the minimum file size threshold for caching in bytes.
286 Files with a size smaller than this threshold will bypass the local disk cache
287 and be downloaded directly from the network upon access.
288 - **Default:** None (no minimum limit is set).
289
290 #### `--cache-max-size <bytes>`
291
292 - **Description:** Sets the maximum file size threshold for caching in bytes.
293 Files with a size larger than this threshold will bypass the local disk cache
294 and be downloaded directly from the network upon access.
295 - **Default:** None (no maximum limit is set).
296
297 ______________________________________________________________________
298
299 ### Network & Performance Options
300
301 #### `--http-header <header>`
302
303 - **Description:** Set one or more custom HTTP headers for requests sent to the
304 mounted server. This option can be specified multiple times.
305 - **Example:**
306 `httpdirfs --http-header "Authorization: Bearer token" --http-header "X-Custom: value" URL mountpoint`
307
308 #### `--max-conns <count>`
309
310 - **Description:** Sets the maximum number of concurrent network connections
311 libcurl is allowed to establish.
312 - **Default:** `6`
313 - **Tip:** Lowering this number reduces load on remote servers and helps prevent
314 rate-limiting or blocking.
315
316 #### `--refresh-timeout <seconds>`
317
318 - **Description:** Sets the duration in seconds after which directory listings
319 are treated as stale and are refetched from the remote server when accessed.
320 - **Default:** `3600` (1 hour)
321
322 #### `--retry-wait <seconds>`
323
324 - **Description:** Sets the delay in seconds to wait before retrying an HTTP
325 request after a connection failure or server error.
326 - **Default:** `5`
327
328 #### `--user-agent <string>`
329
330 - **Description:** Customizes the HTTP `User-Agent` header sent with each
331 request.
332 - **Default:** `HTTPDirFS-1.3.3`
333
334 #### `--no-range-check`
335
336 - **Description:** Skips the built-in HTTP Range check. Normally, HTTPDirFS
337 tests whether the remote server supports HTTP Range requests (required for
338 random-access file seeks). If you know your server supports Range requests but
339 fails the probe, enable this flag.
340 - **Warning:** If the remote server truly does not support Range requests,
341 reading files from the mountpoint will be extremely slow or fail.
342
343 ______________________________________________________________________
344
345 ### Behavioral & Advanced Flags
346
347 #### `--invalid-refresh`
348
349 - **Description:** Tries to refresh and resolve invalid or expired links
350 dynamically when reading directory contents, rather than relying strictly on
351 the refresh timeout.
352
353 #### `--zero-len-is-dir`
354
355 - **Description:** Instructs HTTPDirFS to treat any file listed with a length of
356 `0` bytes as a subdirectory. Useful for servers that do not end directory URLs
357 with `/` in their listings but represent them with a size of zero.
358
359 #### `--single-file-mode`
360
361 - **Description:** Launches HTTPDirFS in Single File Mode. Rather than
362 attempting to mount and traverse a directory listing, it mounts the specified
363 URL as a single virtual file inside the mountpoint. This is highly useful for
364 files hosted on servers that do not present any directory listings.
365
366 ______________________________________________________________________
367
368 ### External Links (`--external-links`)
369
370 When `--external-links` is enabled, HTTPDirFS parses the HTML directory listing
371 of the mounted server and identifies any `<a href>` tags pointing to absolute
372 external (cross-origin) URLs.
373
374 #### How It Works
375
376 - **File and Directory Exposure:** External files and directories will appear
377 alongside local files in the mountpoint. External URLs ending with a trailing
378 slash (`/`) are treated as directories; navigating into them triggers a
379 recursive layout discovery on the remote server.
380 - **First-Wins Deduplication:** If multiple external links produce the same
381 filename after extraction, only the first encountered link is kept.
382 - **Path Sanitization:** Filenames derived from external URLs are automatically
383 sanitized. URL-decoded slash characters (`%2F`) are unescaped and converted to
384 underscores (`_`) to prevent directory traversal or invalid FUSE entry
385 creations.
386 - **Cache Compatibility:** Caching works seamlessly with external links. Cache
387 paths for external files are safely flattened and sanitized within the
388 metadata and data cache directory structures to avoid directory traversal.
389
390 #### Security & Credentials Scoping
391
392 - **Credential Protection:** To prevent credential leakage, HTTP credentials
393 specified with `-u`/`--username` and `-p`/`--password` are strictly scoped to
394 the primary mounted origin. They are **not** forwarded to cross-origin
395 servers.
396 - **Custom HTTP Headers:** Custom HTTP headers set via `--http-header` are also
397 strictly scoped to the primary origin and will not be sent to external hosts.
398 - **Authentication Warnings:** External servers requiring authentication
399 (returning HTTP 401 or 403) will log a warning indicating that credentials are
400 restricted to the main server.
401
402 ______________________________________________________________________
403
404 ### Airsonic / Subsonic Mounting Options
405
406 HTTPDirFS can mount remote Airsonic or Subsonic music collections. When mounted,
407 the music structure is presented locally as virtual directories and files.
408
409 #### `--sonic-username <string>`
410
411 - **Description:** The username to authenticate against your Airsonic / Subsonic
412 server.
413
414 #### `--sonic-password <string>`
415
416 - **Description:** The password to authenticate against your Airsonic / Subsonic
417 server.
418
419 #### `--sonic-id3`
420
421 - **Description:** Enables ID3 presentation mode. Instead of representing the
422 music collection in a flat or default structure, HTTPDirFS dynamically parses
423 metadata and presents the directory layout in an elegant
424 `Artist/Album/Song.mp3` layout.
425
426 #### `--sonic-insecure`
427
428 - **Description:** Forces authentication using the plaintext username and
429 hex-encoded password scheme instead of the modern salted MD5 token handshake.
430 Useful for legacy servers that do not support modern handshakes.