#onedrive #fuse

app onedrive-fuse

Mount OneDrive storage as FUSE filesystem

3 unstable releases

new 0.2.1 Apr 30, 2021
0.2.0 Apr 30, 2021
0.1.0 Apr 25, 2020

#66 in Filesystem

GPL-3.0 license




Mount your Microsoft OneDrive storage as FUSE filesystem.


Use your package manager to install dependencies:

  • openssl
  • fuse (libfuse)

Install it from crates.io:

cargo install onedrive-fuse

For the first time, you should register your own Application (Client) ID for the API access. Read doc/register_app.md for steps.

Login to your OneDrive account with Client ID of your own application. This will prompt a browser window to ask you to login your Microsoft account for OneDrive. After a successful login, the page will redirect your to a blank page whose URL contains nativeclient?code=, then copy the FULL URL, paste it to the terminal and press enter to login.

# Login with read-only access.
onedrive-fuse login --client-id <paste-your-client-id-here>
# Or login with read-write access.
# onedrive-fuse login --read-write --client-id <paste-your-client-id-here>

Your access token will be saved to to XDG config directory, which is default to be ~/.config/onedrive-fuse/credential.json.

Finally, mount your OneDrive to a empty directory. It works in foreground by default, the terminal window should be kept opened. It will fetch the whole tree hierarchy before mounting, please wait for FUSE initialized to be shown and the filesystem is now mounted.

mkdir -p ~/onedrive # The directory to be mounted should be empty.
onedrive-fuse mount ~/onedrive
# Or if you want to read-writea access. The token must be authorized to have read-write access.
# Use it with care. Bugs may corrupt your OneDrive data.
# onedrive-fuse mount ~/onedrive -o permission.readonly=false

Umount the fuse filesystem gracefully. You should NOT directly Ctrl-C or kill the onedrive-fuse instance.

Warning: Wait your upload session to be finished before umounting the filesystem. Currently we don't yet implemented waiting for uploading before shutdown.

fusermount -u ~/onedrive

Features implemented

  • FUSE syscalls
    • Read
      • access
      • forget
      • getattr
      • lookup
      • open
        • O_RDONLY
      • opendir
      • read
      • readdir
      • release
      • releasedir
      • statfs
    • Write
      • create
      • mkdir
      • open
        • O_WRONLY/O_RDWR
        • O_TRUNC
        • O_EXCL
      • rename
      • rmdir
      • setattr
        • size
        • mtime
      • unlink
      • write
    • Other
      • destroy
      • flush
      • fsync
      • fsyncdir
      • init
    • Unsupported
      • bmap
      • getlk
      • getxattr
      • link
      • listxattr
      • mknod
      • readlink
      • removexattr
      • setlk
      • setxattr
      • symlink
  • Cache
    • Statfs cache
    • Inode attributes (stat) cache
    • Directory tree cache
    • Sync remote changes with local cache
    • File read cache
    • File write cache/buffer




~331K SLoC