8000 GitHub - mdminhazulhaque/json-fuse: :file_folder: A FUSE based file system that reads data from JSON file · GitHub
[go: up one dir, main page]

Skip to content
mdminhazulhaquePublic

About

📁 A FUSE based file system that reads data from JSON file

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

JSON Fuse

JSONFuse is a FUSE based file system that:

  • uses a JSON object as source
  • serves the JSON keys as directories
  • serves the JSON values as files

Screen

Motivation

Every week, I try to learn something new. And this week's topic was FUSE. I was going through the source of s3fs whic 6E3D h is a FUSE based file system that uses cURL to communicate with AWS S3 API. So I was thinking I should make a FUSE based file system that will utilize a JSON file.

Known Issues

This file system does not support creating directories/files or deleting/renaming them. Symlink is also not supported because I haven't implemented the required functions.

Also this file system cannot read anything if the JSON has any Array [] inside it. Everything should be Object {}

How to Run

The program is written in Python3. The following line is enough to mount the file system to any existing path.

python3 json-fuse.py source.json /path/to/mount/point

An example run-through would look like this

$ tail example/countries.json
    "Zambia": {
        "city": "Lusaka",
        "population": "17094130",
        "calling_code": "260",
        "continent": "Africa",
        "tld": ".zm"
    },
    "Zimbabwe": {
        "city": "Harare",
        "population": "16529904",
        "calling_code": "263",
        "continent": "Africa",
        "tld": ".zw"
    }
}
$ python3 json-fuse.py example/countries.json /mnt
$ tree /mnt/Zimbabwe
mnt
└── Zimbabwe
    ├── calling_code
    ├── city
    ├── continent
    ├── population
    └── tld
$ cat /mnt/Zimbabwe/tld
.zw
$ cat /mnt/Zimbabwe/continent
Africa

The program will run in foreground because I have set foreground=True. This can be set to False to make it a daemon.

Requirements

  • python3
  • pip3 install fusepy (not python-fuse)

Future Works

  • Add mkdir, rmdir methods to allow creating and deleting directories
  • Add create, write, unlink and utimes methods to allow creating and deleting files
  • Add method for dumping JSON files when files/directories are created

About

📁 A FUSE based file system that reads data from JSON file

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Contributors

Languages

0