From 1c9ce2e15c3b2f6e3b1a4665e134d040eab490c1 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:00:20 +0000 Subject: [PATCH 01/15] dfuse.example.simplefs: Implement Operations.access This is necessary to actually access the filesystem. --- example/simplefs.d | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/example/simplefs.d b/example/simplefs.d index 2a12ef5..47629fa 100644 --- a/example/simplefs.d +++ b/example/simplefs.d @@ -46,6 +46,11 @@ class SimpleFS : Operations throw new FuseException(ENOENT); } + + override bool access(const(char)[] path, int mode) + { + return true; + } } int main(string[] args) From cdfbd13aebc4e64e49026efcfcd632094f5bae58 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:08:06 +0000 Subject: [PATCH 02/15] Delete Makefile Rationale: - It has been broken for a while. - Using make to build D software is a poor fit, due to D's module system and package dependencies. - The Makefile seemed to contain some organization-specific conventions, which there is no reason to maintain in the dlang-community fork. Follow-up commits will update the documentation accordingly, and improve the Dub configuration file to cover the Makefile's functionality. --- Makefile | 82 -------------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index daef3a7..0000000 --- a/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -# -# Copyright (c) 2014, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed under the Boost-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. -# -VERSION=0.4.0-dev -INTERNAL_VERSION=0004 - -product=libdfuse-$(VERSION) - -PREFIX=/usr/local -DMD=dmd -DMDFLAGS= - -sources = source/c/fuse/fuse.d source/c/fuse/common.d source/dfuse/fuse.d -uname := $(shell uname -s) - -# Define variables and buildmodes depending on ENABLE_DEBUG, ENABLE_64BIT and -# operating system. -buildmode=release -ifeq ($(ENABLE_DEBUG),1) - MODE=-debug -g - buildmode=debug -else - MODE=-release -O -inline - buildmode=release -endif - -bitmode=64 -ifeq ($(uname),Darwin) -ifeq ($(ENABLE_64BIT),1) - MODE+=-version=DARWIN_USE_64_BIT_INODE - LIBS=-L-losxfuse - bitmde=64 -else - LIBS=-L-losxfuse_i32 - bitmode=32 -endif -endif - -ifeq ($(uname),Linux) - LIBS=-L-lfuse - bitmode=64 -endif - -# Define build directories and main target for libs -builddir=build/$(buildmode)/$(bitmode) - -ifeq ($(uname),Linux) - artifact=$(builddir)/$(product).so -endif -ifeq ($(uname),Darwin) - artifact=$(builddir)/$(product).dylib -endif - -all:: dfuse - -$(builddir): - mkdir -p $(builddir) - -$(builddir)/$(product).so: $(sources) - $(DMD) -w $(MODE) -shared $(LIBS) -version=$(INTERNAL_VERSION) -of$@ $(sources) - -$(builddir)/$(product).dylib: $(sources) - $(DMD) -w $(MODE) -shared $(LIBS) -version=$(INTERNAL_VERSION) -of$@ $(sources) - -simplefs: example/simplefs.d $(sources) - $(DMD) -w -debug -g $(LIBS) -of$@ example/simplefs.d $(sources) - -examples: simplefs - -dfuse: $(artifact) - -clean: - @(rm simplefs 2>/dev/null || exit 0) - @(rm -r $(artifact) || exit 0) - @(rm -rf build/ || exit 0) - -.PHONY: dfuse all clean examples From f3a686c31a3c00e9d6b7d542ce28432f07404661 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:13:25 +0000 Subject: [PATCH 03/15] dub.json: Translate to SDLang Though less standard, SDLang is considerably more readable, and unlike JSON, is documentable. --- dub.json | 20 -------------------- dub.sdl | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 20 deletions(-) delete mode 100644 dub.json create mode 100644 dub.sdl diff --git a/dub.json b/dub.json deleted file mode 100644 index 13c6dfb..0000000 --- a/dub.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "dfuse", - "description": "A D binding for libfuse", - "authors": ["David Soria Parra"], - "copyright": "Copyright (c) 2014, Facebook, Inc.", - "homepage": "http://github.com/dlang-community/dfuse", - "license": "BSL-1.0", - "dependencies": {}, - "configurations": [{ - "name": "dfuse-osx", - "targetType": "library", - "platforms": ["osx"], - "libs": ["osxfuse_i32"] - }, { - "name": "dfuse-linux", - "targetType": "library", - "platforms": ["linux"], - "libs": ["fuse"] - }] -} diff --git a/dub.sdl b/dub.sdl new file mode 100644 index 0000000..18271b8 --- /dev/null +++ b/dub.sdl @@ -0,0 +1,16 @@ +name "dfuse" +description "A D binding for libfuse" +authors "David Soria Parra" +copyright "Copyright (c) 2014, Facebook, Inc." +homepage "http://github.com/dlang-community/dfuse" +license "BSL-1.0" +targetType "library" + +configuration "dfuse-osx" { + platforms "osx" + libs "osxfuse_i32" +} +configuration "dfuse-linux" { + platforms "linux" + libs "fuse" +} From dbc4727d75a514db1ab9439ffa9b2e4b8bfa76b4 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:18:41 +0000 Subject: [PATCH 04/15] dub.sdl: Use https:// --- dub.sdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dub.sdl b/dub.sdl index 18271b8..f15c906 100644 --- a/dub.sdl +++ b/dub.sdl @@ -2,7 +2,7 @@ name "dfuse" description "A D binding for libfuse" authors "David Soria Parra" copyright "Copyright (c) 2014, Facebook, Inc." -homepage "http://github.com/dlang-community/dfuse" +homepage "https://github.com/dlang-community/dfuse" license "BSL-1.0" targetType "library" From 394eb4403cb541225a7dc1b37dd9eb98ac390bd8 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:19:03 +0000 Subject: [PATCH 05/15] dub.sdl: Merge default configurations No reason to have two different configurations when we can select the libraries to link with by platform. --- dub.sdl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/dub.sdl b/dub.sdl index f15c906..bb6e79d 100644 --- a/dub.sdl +++ b/dub.sdl @@ -6,11 +6,8 @@ homepage "https://github.com/dlang-community/dfuse" license "BSL-1.0" targetType "library" -configuration "dfuse-osx" { - platforms "osx" - libs "osxfuse_i32" -} -configuration "dfuse-linux" { - platforms "linux" - libs "fuse" +configuration "default" { + platforms "osx" "linux" + libs "fuse" platform="linux" + libs "osxfuse_i32" platform="osx" } From c3999943a7904349bffeed218652b733689f0d9d Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:19:30 +0000 Subject: [PATCH 06/15] dub.sdl: Add 64-bit OSX configuration Port this feature from the deleted Makefile. --- dub.sdl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dub.sdl b/dub.sdl index bb6e79d..cdda305 100644 --- a/dub.sdl +++ b/dub.sdl @@ -11,3 +11,8 @@ configuration "default" { libs "fuse" platform="linux" libs "osxfuse_i32" platform="osx" } +configuration "dfuse-osx-64" { + platforms "osx" + libs "osxfuse" + versions "DARWIN_USE_64_BIT_INODE" +} From f604b375efa2a7cd31676d8ca22034e9b7349d3b Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:20:01 +0000 Subject: [PATCH 07/15] example: Add dub.sdl Allow building the example using Dub. --- example/dub.sdl | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 example/dub.sdl diff --git a/example/dub.sdl b/example/dub.sdl new file mode 100644 index 0000000..5a111ed --- /dev/null +++ b/example/dub.sdl @@ -0,0 +1,5 @@ +name "simplefs" +targetType "executable" +sourceFiles "simplefs.d" + +dependency "dfuse" version="*" path=".." From af05df16b526bd116ef92b3ea92fa5aec59ad091 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:20:42 +0000 Subject: [PATCH 08/15] README: Update minimal filesystem requirements Implementing Operations.access seems to be required. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d6c5f86..5e53e9b 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ class MyFS : Operations } ``` -A minimal filesystem implements `Operations.getattr()`, `Operations.readdir()`, `Operations.read()`. See [dfuse/fuse.d](https://github.com/dlang-community/dfuse/blob/master/source/dfuse/fuse.d) for implementation specific details. +A minimal filesystem implements `Operations.getattr()`, `Operations.access()`, `Operations.readdir()`, `Operations.read()`. See [dfuse/fuse.d](https://github.com/dlang-community/dfuse/blob/master/source/dfuse/fuse.d) for implementation specific details. To mount a filesystem use a Fuse object and call mount: ```D From 02de6d092e91953b4912e7fe60956f1383dd1487 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:20:59 +0000 Subject: [PATCH 09/15] README: Update example build instructions --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e53e9b..8e5f9e0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ HTTP libraries, etc. For more information about fuse see: http://fuse.sourceforg A simple filesystems implementing a directory listing can be found in the [example/](https://github.com/dlang-community/dfuse/tree/master/example) directory. You can build the examples using: ```Shell -$ make examples +$ cd example +$ dub build # or: $ dmd -i -I../source -L-lfuse simplefs.d $ mkdir /mnt/simplefs $ ./simplefs /mnt/simplefs ``` From 0754aa6123b5887fadb66aa287f6d19624076495 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:24:11 +0000 Subject: [PATCH 10/15] README: Update build instructions to use Dub --- README.md | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8e5f9e0..e9de392 100644 --- a/README.md +++ b/README.md @@ -66,15 +66,16 @@ dfuse requires: * DMD/Druntime/Phobos >= 2.065 ## Building dfuse -dfuse comes with a standard makefile that assumes that DMD (the D-compiler) is -in your $PATH. +dfuse comes with a [Dub](https://dub.pm/) configuration file, making it usable as a Dub package. + +Alternatively, it is usable with common D recursive compilation tools (`dmd -i` / `rdmd` / `rund`). ### Linux In order to compile dfuse on Linux: ```Shell -$ make dfuse +$ dub build -b release or -$ make dfuse ENABLE_DEBUG=1 +$ dub build -b debug to build a debug version ``` @@ -89,22 +90,15 @@ the size of the inode. To build just run ```Shell -$ make dfuse +$ dub build ``` If you want to compile with 64bit inodes you need a at least DMD, Druntime, Phobos in version 2.066: ```Shell -$ make dfuse ENABLE_64BIT=1 +$ dub build -c dfuse-osx-64 ``` -### Dub -dfuse comes with experimental support for [dub](http://code.dlang.org/), a package manager for D. See the dub documentation how to build and use dub. - -## Installing dfuse -At the moment the dfuse makefile doesn't support an install target. It is -recommended to just include the library in a project at this point. - ## How dfuse works dfuse is a simple D wrapper. It exposes a lowelevel interface to the libfuse C functions in c/fuse/fuse.d. The lowlevel interface preserves C types. From ecd10dca1feb1e99378ea4071e2669a7b633cbbf Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:34:05 +0000 Subject: [PATCH 11/15] .github/workflows/test.yml: Add GitHub test workflow --- .github/workflows/test.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f54c1fe --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: test +on: [ push, pull_request ] +jobs: + test: + strategy: + matrix: + os: [ubuntu-20.04, macos-10.15] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: dlang-community/setup-dlang@v1 + with: + compiler: dmd-2.096.0 + - name: Setup (Linux) + if: runner.os == 'Linux' + run: | + sudo apt install libfuse-dev + - name: Setup (macOS) + if: runner.os == 'macOS' + run: | + brew install --cask osxfuse + - name: Test + run: | + dub build + dub --root=example build + - name: Test (64-bit inodes) + if: runner.os == 'macOS' + run: | + dub build -c dfuse-osx-64 + dub --root=example build --override-config=dfuse/dfuse-osx-64 From d127c3c8675416a2e0824e77072da8bb69286300 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 00:47:37 +0000 Subject: [PATCH 12/15] c.fuse.fuse_common: Fix compilation on macOS --- source/c/fuse/fuse_common.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/c/fuse/fuse_common.d b/source/c/fuse/fuse_common.d index 11ec56b..d67ffd7 100644 --- a/source/c/fuse/fuse_common.d +++ b/source/c/fuse/fuse_common.d @@ -22,7 +22,7 @@ enum FUSE_MINOR_VERSION = 9; auto FUSE_MAKE_VERSION(Maj, Min)(Maj maj, Min min) { return ((maj) * 10 + (min)); } enum FUSE_VERSION = FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION); -static assert(_FILE_OFFSET_BITS == 64); +version (linux) static assert(_FILE_OFFSET_BITS == 64); extern (C): From a26b628ec74bb655d81400806bfaf5b262dc160a Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 01:08:28 +0000 Subject: [PATCH 13/15] Drop support for 32-bit inodes on macOS These were removed from Druntime back in 2015. --- .github/workflows/test.yml | 5 ----- README.md | 22 +--------------------- dub.sdl | 8 +------- 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f54c1fe..07455c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,8 +23,3 @@ jobs: run: | dub build dub --root=example build - - name: Test (64-bit inodes) - if: runner.os == 'macOS' - run: | - dub build -c dfuse-osx-64 - dub --root=example build --override-config=dfuse/dfuse-osx-64 diff --git a/README.md b/README.md index e9de392..fd83d2f 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ dfuse comes with a [Dub](https://dub.pm/) configuration file, making it usable a Alternatively, it is usable with common D recursive compilation tools (`dmd -i` / `rdmd` / `rund`). -### Linux +### Dub In order to compile dfuse on Linux: ```Shell $ dub build -b release @@ -79,26 +79,6 @@ $ dub build -b debug to build a debug version ``` -### MacOS -MacOS supports two inode sizes which are both supported by OSXfuse, however when -compiling dfuse you have to be aware which OSXfuse should be linked. - -By default dfuse is trying to build with a 32bit inode size and link against -osxfuse_i32 which is part of OSXfuse for compatibility. Please note that your -library itself will still be 64bit on a 64bit system. The setting only affects -the size of the inode. - -To build just run -```Shell -$ dub build -``` - -If you want to compile with 64bit inodes you need a at least DMD, Druntime, -Phobos in version 2.066: -```Shell -$ dub build -c dfuse-osx-64 -``` - ## How dfuse works dfuse is a simple D wrapper. It exposes a lowelevel interface to the libfuse C functions in c/fuse/fuse.d. The lowlevel interface preserves C types. diff --git a/dub.sdl b/dub.sdl index cdda305..91a92db 100644 --- a/dub.sdl +++ b/dub.sdl @@ -8,11 +8,5 @@ targetType "library" configuration "default" { platforms "osx" "linux" - libs "fuse" platform="linux" - libs "osxfuse_i32" platform="osx" -} -configuration "dfuse-osx-64" { - platforms "osx" - libs "osxfuse" - versions "DARWIN_USE_64_BIT_INODE" + libs "fuse" } From 91e22aa9d6d65717d709fd56b7331b78df70ad19 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 01:08:52 +0000 Subject: [PATCH 14/15] README: Document recursive compilation --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index fd83d2f..8f5043a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,11 @@ $ dub build -b debug to build a debug version ``` +### Recursive compilation +- Make sure the dfuse `source` directory is in your compiler search path. +- `import dfuse.fuse;` in your program. +- Link against the `fuse` library, e.g. by adding `-L-lfuse` to the compiler's command line, or by adding `pragma(lib, "fuse");` in your program. + ## How dfuse works dfuse is a simple D wrapper. It exposes a lowelevel interface to the libfuse C functions in c/fuse/fuse.d. The lowlevel interface preserves C types. From 567ab31ff9979fd723e350de726638ace79a32c7 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 29 Mar 2021 01:11:31 +0000 Subject: [PATCH 15/15] README: Add badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f5043a..6b328ce 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# dfuse +# dfuse [![test](https://github.com/dlang-community/dfuse/actions/workflows/test.yml/badge.svg)](https://github.com/dlang-community/dfuse/actions/workflows/test.yml) *dfuse* is a [D language binding](http://dlang.org) for the high level [fuse](http://fuse.sourceforge.net) library. It allows to write a fuse filesystem for Linux or Mac OS (using [osxfuse](http://osxfuse.github.io)) in D.