Giter VIP home page Giter VIP logo

emptyfs's Introduction

emptyfs - A trivial macOS VFS plug-in implementation

Summary

emptyfs is a trivial VFS plug-in(kernel extension), its volumes are completely empty(except for the root directory).

This simple VFS plug-in is a minimal implementation, you can use it to explore VFS behaviours, or as a template as your own VFS plug-in.

Build

You must install Apple's Command Line Tools as a minimal build environment, or Xcode as a full build environment in App Store.

$ make            # Debug build
$ make release    # Release build

Theoretically, this kext can be compile and run in macOS 10.4+, yet currently only from 10.10 up to 10.14 are tested.

If you compile in macOS >= 10.13 and wants the kext to stay compatible with macOS <= 10.12, you should specify -DKASAN or -D_FORTIFY_SOURCE=0 to CPPFLAGS, for more info, please refer to issues#1

Debugging

# Under kext/ directory
$ make load			# Load emptyfs kext
$ make stat			# Print status of emptyfs kext
$ make unload			# Unload emptyfs kext

TODO: add info about kext logging

Install

# Under kext/ directory
$ make install
$ make uninstall		# In case you want to uninstall

You can specify PREFIX variable to make for install location, the default is /Library/Extensions

TODO: add docs about HOWTO load at boot-up time

After installation, the kext will be loaded automatically in each boot.

Use of emptyfs

To test the VFS plug-in, you must specify what device node to mounted on. Simplest approach is to create a disk image:

# Create a disk image (name: test.dmg size: 1MB type: EMPTYFS)
$ hdiutil create -size 1m -partitionType EMPTYFS test
created: /Users/lynnl/test.dmg

$ file test.dmg
test.dmg: Apple Driver Map, blocksize 512, blockcount 2048, devtype 0, devid 0, driver count 0, contains[@0x200]: Apple Partition Map, map block count 2, start block 1, block count 63, name Apple, type Apple_partition_map, valid, allocated, contains[@0x400]: Apple Partition Map, map block count 2, start block 64, block count 1984, name disk image, type EMPTYFS, valid, allocated, readable, writable, mount at startup

Then attach the disk image with -nomount flag(.: the system won't automatically mount the volumes on the image):

# The first two volumes are image scheme and map partition
#  We cares about the last one(i.e. EMPTYFS)
$ hdiutil attach -nomount test.dmg
/dev/disk2          	Apple_partition_scheme
/dev/disk2s1        	Apple_partition_map
/dev/disk2s2        	EMPTYFS

After you load emptyfs kext, you can create a mount point and mount the file system:

$ sudo kextload emptyfs.kext
$ mkdir emptyfs_mp
$ ./mount_emptyfs /dev/disk2s2 emptyfs_mp

Use mount(8) to check mount info and explore the file system:

$ mount | grep emptyfs
/dev/disk2s2 on /Users/lynnl/emptyfs_mp (emptyfs, local, nodev, noexec, nosuid, read-only, noowners, mounted by lynnl)

$ ls -la emptyfs_mp
total 8
dr-xr-xr-x   2 lynnl  staff  528 Dec 27 22:00 .
drwxr-xr-x+ 19 lynnl  staff  608 Dec 27 21:59 ..

$ stat emptyfs_mp
16777226 2 dr-xr-xr-x 2 lynnl staff 0 528 "Dec 27 22:00:25 2018" "Dec 27 22:00:25 2018" "Dec 27 22:00:25 2018" "Dec 27 22:00:25 2018" 4096 8 0 emptyfs_mp

When you explore the file system thoroughly, you can first umount(8) the file system and then unload the kext:

$ unmount emptyfs_mp
$ sudo kextunload emptyfs.kext

Unranked references

EmptyFS - A very simple VFS plug-in that mounts a volume that is completely empty

MFSLives - Sample VFS plug-in for the Macintosh File System (MFS) volume format, as used on 400KB floppies

mac9p - 9P for Mac

antekone's cross-reference search site

FreeBSD and Linux Kernel Cross-Reference

Darwin kernel miscfs

Darwin kernel NFS

Darwin kernel NTFS

Darwin kernel msdosfs

Darwin kernel autofs

Darwin kernel cddafs

Darwin kernel hfs

Darwin kernel webdavfs

emptyfs's People

Contributors

leiless avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.