├── .gitignore ├── README.md ├── filesystems-c ├── clock │ ├── .gitignore │ ├── Makefile │ └── clock_ll.c ├── grabfs │ ├── .gitignore │ ├── COPYING │ ├── Cocoa │ │ ├── .gitignore │ │ ├── English.lproj │ │ │ ├── InfoPlist.strings │ │ │ └── MainMenu.nib │ │ │ │ ├── designable.nib │ │ │ │ └── keyedobjects.nib │ │ ├── GrabFSApplication.icns │ │ ├── GrabFSVolume.icns │ │ ├── GrabFS_Prefix.pch │ │ ├── Info.plist │ │ ├── WindowFS.xcodeproj │ │ │ └── project.pbxproj │ │ └── main.m │ ├── GetPID.c │ ├── GetPID.h │ ├── Makefile │ ├── windowfs.cc │ ├── windowfs_windows.cc │ └── windowfs_windows.h ├── hello │ ├── .gitignore │ ├── Makefile │ ├── hello.c │ └── hello_ll.c ├── loopback │ ├── .gitignore │ ├── Makefile │ └── loopback.c ├── procfs │ ├── .gitignore │ ├── COPYING │ ├── Makefile │ ├── README │ ├── procfs.cc │ ├── procfs.plist │ ├── procfs_displays.cc │ ├── procfs_displays.h │ ├── procfs_proc_info.cc │ ├── procfs_proc_info.h │ ├── procfs_tpm.cc │ ├── procfs_tpm.h │ ├── procfs_windows.cc │ ├── procfs_windows.h │ └── sequencegrab │ │ ├── CSGCamera.h │ │ ├── CSGCamera.m │ │ ├── CSGImage.h │ │ ├── CSGImage.m │ │ ├── CocoaSequenceGrabber.h │ │ ├── Makefile │ │ ├── procfs_sequencegrab.h │ │ └── procfs_sequencegrab.mm ├── unixfs │ ├── .gitignore │ ├── Makefile │ ├── ancientfs │ │ ├── .gitignore │ │ ├── AncientUnix.pdf │ │ ├── COPYRIGHT.txt │ │ ├── Makefile │ │ ├── ancientfs.h │ │ ├── ancientfs_2.11bsd.c │ │ ├── ancientfs_2.11bsd.h │ │ ├── ancientfs_2.9bsd.c │ │ ├── ancientfs_2.9bsd.h │ │ ├── ancientfs_32v.c │ │ ├── ancientfs_32v.h │ │ ├── ancientfs_ar.c │ │ ├── ancientfs_ar.h │ │ ├── ancientfs_bcpio.c │ │ ├── ancientfs_bcpio.h │ │ ├── ancientfs_cpio_newc.c │ │ ├── ancientfs_cpio_newc.h │ │ ├── ancientfs_cpio_odc.c │ │ ├── ancientfs_cpio_odc.h │ │ ├── ancientfs_dtp.c │ │ ├── ancientfs_dtp.h │ │ ├── ancientfs_dump.c │ │ ├── ancientfs_dump.h │ │ ├── ancientfs_dump1024.c │ │ ├── ancientfs_dumpvn.c │ │ ├── ancientfs_dumpvn.h │ │ ├── ancientfs_dumpvn1024.c │ │ ├── ancientfs_itp.c │ │ ├── ancientfs_itp.h │ │ ├── ancientfs_mainx.c │ │ ├── ancientfs_oar.c │ │ ├── ancientfs_oar.h │ │ ├── ancientfs_tap.c │ │ ├── ancientfs_tap.h │ │ ├── ancientfs_tar.c │ │ ├── ancientfs_tar.h │ │ ├── ancientfs_tp.c │ │ ├── ancientfs_tp.h │ │ ├── ancientfs_v1,2,3.c │ │ ├── ancientfs_v1,2,3.h │ │ ├── ancientfs_v10.c │ │ ├── ancientfs_v4,5,6.c │ │ ├── ancientfs_v4,5,6.h │ │ ├── ancientfs_v7.c │ │ ├── ancientfs_v7.h │ │ ├── ancientfs_voar.c │ │ └── ancientfs_voar.h │ ├── common │ │ ├── darwin │ │ │ └── queue.h │ │ ├── linux │ │ │ ├── COPYING │ │ │ ├── kernel │ │ │ │ ├── fs │ │ │ │ │ └── ufs │ │ │ │ │ │ ├── swab.h │ │ │ │ │ │ ├── ufs.h │ │ │ │ │ │ ├── ufs_fs.h │ │ │ │ │ │ ├── util.c │ │ │ │ │ │ └── util.h │ │ │ │ ├── include │ │ │ │ │ ├── asm │ │ │ │ │ │ └── div64.h │ │ │ │ │ └── linux │ │ │ │ │ │ ├── bitops.h │ │ │ │ │ │ ├── blockgroup_lock.h │ │ │ │ │ │ ├── buffer_head.h │ │ │ │ │ │ ├── ctype.h │ │ │ │ │ │ ├── div64.h │ │ │ │ │ │ ├── ext2_fs.h │ │ │ │ │ │ ├── ext2_fs_sb.h │ │ │ │ │ │ ├── fs.h │ │ │ │ │ │ ├── highmem.h │ │ │ │ │ │ ├── kernel.h │ │ │ │ │ │ ├── magic.h │ │ │ │ │ │ ├── minix_fs.h │ │ │ │ │ │ ├── module.h │ │ │ │ │ │ ├── parser.h │ │ │ │ │ │ ├── percpu_counter.h │ │ │ │ │ │ ├── rbtree.h │ │ │ │ │ │ ├── sched.h │ │ │ │ │ │ ├── slab.h │ │ │ │ │ │ ├── smp_lock.h │ │ │ │ │ │ ├── stat.h │ │ │ │ │ │ ├── stddef.h │ │ │ │ │ │ ├── string.h │ │ │ │ │ │ ├── swap.h │ │ │ │ │ │ └── types.h │ │ │ │ └── lib │ │ │ │ │ └── parser.c │ │ │ ├── linux.c │ │ │ └── linux.h │ │ └── unixfs │ │ │ ├── unixfs.c │ │ │ ├── unixfs.h │ │ │ ├── unixfs_common.h │ │ │ ├── unixfs_internal.c │ │ │ └── unixfs_internal.h │ ├── minixfs │ │ ├── .gitignore │ │ ├── COPYING │ │ ├── Makefile │ │ ├── itree_common.c │ │ ├── itree_v1.c │ │ ├── itree_v2.c │ │ ├── minixfs.c │ │ ├── minixfs.h │ │ ├── minixfs_mainx.c │ │ └── unixfs_minixfs.c │ ├── sysvfs │ │ ├── .gitignore │ │ ├── COPYING │ │ ├── Makefile │ │ ├── sysvfs.c │ │ ├── sysvfs.h │ │ ├── sysvfs_mainx.c │ │ └── unixfs_sysvfs.c │ └── ufs │ │ ├── .gitignore │ │ ├── COPYING │ │ ├── Makefile │ │ ├── ufs.c │ │ ├── ufs.h │ │ ├── ufs_mainx.c │ │ └── unixfs_ufs.c └── verybigfs │ ├── .gitignore │ ├── Makefile │ └── verybigfs.c ├── filesystems-objc ├── AccessibilityFS │ ├── .gitignore │ ├── AccessibilityFS.xcodeproj │ │ └── project.pbxproj │ ├── AccessibilityFS_Prefix.pch │ ├── ReadMe.html │ ├── Resources │ │ ├── AccessibilityFSApp.icns │ │ ├── AccessibilityFSMount.icns │ │ ├── English.lproj │ │ │ ├── InfoPlist.strings │ │ │ └── MainMenu.nib │ │ │ │ ├── classes.nib │ │ │ │ ├── info.nib │ │ │ │ └── keyedobjects.nib │ │ └── Info.plist │ ├── Source │ │ ├── AccessibilityController.h │ │ ├── AccessibilityController.m │ │ ├── AccessibilityFS.h │ │ ├── AccessibilityFS.m │ │ ├── command_main.c │ │ └── main.m │ └── Toolbox │ │ ├── GTMAXUIElement.h │ │ └── GTMAXUIElement.m ├── COPYING ├── HelloFS │ ├── .gitignore │ ├── English.lproj │ │ ├── InfoPlist.strings │ │ └── MainMenu.nib │ │ │ ├── designable.nib │ │ │ └── keyedobjects.nib │ ├── HelloController.h │ ├── HelloController.m │ ├── HelloFS.xcodeproj │ │ └── project.pbxproj │ ├── HelloFS_Prefix.pch │ ├── HelloFuseFileSystem.h │ ├── HelloFuseFileSystem.m │ ├── Info.plist │ ├── Resources │ │ ├── Fuse.icns │ │ └── hellodoc.icns │ └── main.m ├── LoopbackFS │ ├── .gitignore │ ├── English.lproj │ │ └── MainMenu.nib │ │ │ ├── designable.nib │ │ │ └── keyedobjects.nib │ ├── Info.plist │ ├── LoopbackController.h │ ├── LoopbackController.m │ ├── LoopbackFS.entitlements │ ├── LoopbackFS.h │ ├── LoopbackFS.icns │ ├── LoopbackFS.m │ ├── LoopbackFS.xcodeproj │ │ └── project.pbxproj │ ├── LoopbackFS_Prefix.pch │ ├── README.txt │ ├── loop.d │ ├── loop.m │ └── main.m ├── SpotlightFS │ ├── .gitignore │ ├── Resources │ │ ├── DynamicFolderBlue.icns │ │ ├── English.lproj │ │ │ ├── InfoPlist.strings │ │ │ └── MainMenu.nib │ │ │ │ ├── classes.nib │ │ │ │ ├── info.nib │ │ │ │ └── keyedobjects.nib │ │ ├── Info.plist │ │ ├── SmartFolder.icns │ │ ├── SmartFolderBlue.icns │ │ ├── SpotlightFSApp.icns │ │ └── SpotlightFSMount.icns │ ├── Source │ │ ├── SpotlightFS.h │ │ ├── SpotlightFS.m │ │ ├── SpotlightFSController.h │ │ ├── SpotlightFSController.m │ │ └── main.m │ ├── SpotlightFS.xcodeproj │ │ └── project.pbxproj │ └── SpotlightFS_Prefix.pch ├── Support │ ├── NSError+POSIX.h │ ├── NSError+POSIX.m │ ├── NSImage+IconData.h │ ├── NSImage+IconData.m │ ├── YTVideo.h │ └── YTVideo.m └── YTFS │ ├── .gitignore │ ├── English.lproj │ ├── InfoPlist.strings │ └── MainMenu.xib │ ├── Info.plist │ ├── README.txt │ ├── YTFS.d │ ├── YTFS.icns │ ├── YTFS.xcodeproj │ └── project.pbxproj │ ├── YTFS_Controller.h │ ├── YTFS_Controller.m │ ├── YTFS_Filesystem.h │ ├── YTFS_Filesystem.m │ ├── YTFS_Prefix.pch │ └── main.m ├── filesystems-swift └── LoopbackFS │ ├── LICENSE │ ├── LoopbackFS.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ └── trispo.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── LoopbackFS │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── MainMenu.xib │ ├── Bridging-Header.h │ ├── Info.plist │ ├── LoopbackFS.swift │ ├── NSError+POSIX.swift │ └── Resources │ └── LoopbackFS.icns └── support ├── debugging └── macfuse_u_fuse_fs.d └── testing └── posix_compat_test ├── Makefile └── posix_compat_test.cc /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository contains legacy demo file systems that are unmaintained. Please refer to https://github.com/macfuse/demo for maintained demo file systems. 2 | -------------------------------------------------------------------------------- /filesystems-c/clock/.gitignore: -------------------------------------------------------------------------------- 1 | *.dSYM/ 2 | *.a 3 | *.dylib 4 | *.o 5 | 6 | .DS_Store 7 | clock_ll 8 | -------------------------------------------------------------------------------- /filesystems-c/clock/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = clock_ll 2 | 3 | # Root for OSXFUSE includes and libraries 4 | OSXFUSE_ROOT = /usr/local 5 | #OSXFUSE_ROOT = /opt/local 6 | 7 | INCLUDE_DIR = $(OSXFUSE_ROOT)/include/osxfuse/fuse 8 | LIBRARY_DIR = $(OSXFUSE_ROOT)/lib 9 | 10 | CC ?= gcc 11 | 12 | CFLAGS_OSXFUSE = -I$(INCLUDE_DIR) -L$(LIBRARY_DIR) 13 | CFLAGS_OSXFUSE += -DFUSE_USE_VERSION=26 14 | CFLAGS_OSXFUSE += -D_FILE_OFFSET_BITS=64 15 | CFLAGS_OSXFUSE += -D_DARWIN_USE_64_BIT_INODE 16 | 17 | CFLAGS_EXTRA = -Wall -g $(CFLAGS) 18 | 19 | LIBS = -losxfuse -lpthread 20 | 21 | .c: 22 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -o $@ $< $(LIBS) 23 | 24 | all: $(TARGETS) 25 | 26 | clock_ll: clock_ll.c 27 | 28 | clean: 29 | rm -f $(TARGETS) *.o 30 | rm -rf *.dSYM 31 | -------------------------------------------------------------------------------- /filesystems-c/grabfs/.gitignore: -------------------------------------------------------------------------------- 1 | *.dSYM/ 2 | *.a 3 | *.dylib 4 | *.o 5 | 6 | .DS_Store 7 | windowfs 8 | -------------------------------------------------------------------------------- /filesystems-c/grabfs/Cocoa/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1 2 | *.mode1v3 3 | *.mode2v3 4 | *.perspective 5 | *.perspectivev3 6 | *.pbxuser 7 | 8 | build/ 9 | project.xcworkspace/ 10 | xcuserdata/ 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /filesystems-c/grabfs/Cocoa/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/grabfs/Cocoa/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /filesystems-c/grabfs/Cocoa/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/grabfs/Cocoa/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /filesystems-c/grabfs/Cocoa/GrabFSApplication.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/grabfs/Cocoa/GrabFSApplication.icns -------------------------------------------------------------------------------- /filesystems-c/grabfs/Cocoa/GrabFSVolume.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/grabfs/Cocoa/GrabFSVolume.icns -------------------------------------------------------------------------------- /filesystems-c/grabfs/Cocoa/GrabFS_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'GrabFS' target in the 'GrabFS' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /filesystems-c/grabfs/Cocoa/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | GrabFSApplication 11 | CFBundleIdentifier 12 | com.osxbook.filesystems.GrabFS 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSMinimumSystemVersion 26 | 10.5 27 | LSUIElement 28 | 1 29 | NSHumanReadableCopyright 30 | © Amit Singh (osxbook.com), 2007-2008 31 | NSMainNibFile 32 | MainMenu 33 | NSPrincipalClass 34 | NSApplication 35 | CFBundleGetInfoString 36 | GrabFS 1.0, © Amit Singh (osxbook.com), 2007-2008 37 | 38 | 39 | -------------------------------------------------------------------------------- /filesystems-c/grabfs/Cocoa/main.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amit Singh. All Rights Reserved. 3 | * http://osxbook.com 4 | */ 5 | 6 | #import 7 | 8 | int 9 | main(int argc, char *argv[]) 10 | { 11 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 12 | 13 | NSString *bin = [[NSBundle mainBundle] pathForResource:@"windowfs" 14 | ofType:NULL]; 15 | NSString *icns = [[NSBundle mainBundle] pathForResource:@"GrabFSVolume" 16 | ofType:@"icns"]; 17 | 18 | const char *bin_utf8 = [bin UTF8String]; 19 | const char *icns_utf8 = [icns UTF8String]; 20 | 21 | char volicon_arg[4096]; 22 | snprintf(volicon_arg, 4096, "-ovolicon=%s", icns_utf8); 23 | 24 | if (fork() == 0) { 25 | execl(bin_utf8, bin_utf8, volicon_arg, NULL); 26 | } 27 | 28 | [pool release]; 29 | 30 | exit(0); 31 | } 32 | -------------------------------------------------------------------------------- /filesystems-c/grabfs/GetPID.h: -------------------------------------------------------------------------------- 1 | /* 2 | * From Apple DTS Sample Code. 3 | */ 4 | 5 | #if !defined(__DTSSampleCode_GetPID__) 6 | #define __DTSSampleCode_GetPID__ 1 7 | 8 | #include 9 | #include 10 | 11 | #if defined(__cplusplus) 12 | extern "C" { 13 | #endif 14 | 15 | enum { 16 | kSuccess = 0, 17 | kCouldNotFindRequestedProcess = -1, 18 | kInvalidArgumentsError = -2, 19 | kErrorGettingSizeOfBufferRequired = -3, 20 | kUnableToAllocateMemoryForBuffer = -4, 21 | kPIDBufferOverrunError = -5 22 | }; 23 | 24 | int GetAllPIDsForProcessName(const char* ProcessName, 25 | pid_t ArrayOfReturnedPIDs[], 26 | const unsigned int NumberOfPossiblePIDsInArray, 27 | unsigned int* NumberOfMatchesFound, 28 | int* SysctlError); 29 | 30 | int GetPIDForProcessName(const char* ProcessName); 31 | 32 | #if defined(__cplusplus) 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /filesystems-c/grabfs/Makefile: -------------------------------------------------------------------------------- 1 | # windowfs file system for Mac OS X 2 | # 3 | # Copyright 2012 Benjamin Fleischer. All Rights Reserved. 4 | # Copyright 2007-2008 Amit Singh (osxbook.com). All Rights Reserved. 5 | 6 | # Root for OSXFUSE includes and libraries 7 | OSXFUSE_ROOT = /usr/local 8 | #OSXFUSE_ROOT = /opt/local 9 | 10 | INCLUDE_DIR = $(OSXFUSE_ROOT)/include/osxfuse/fuse 11 | LIBRARY_DIR = $(OSXFUSE_ROOT)/lib 12 | 13 | CC ?= gcc 14 | CXX ?= g++ 15 | 16 | OSXFUSE_CFLAGS = -I$(INCLUDE_DIR) 17 | OSXFUSE_CFLAGS += -D_FILE_OFFSET_BITS=64 18 | OSXFUSE_CFLAGS += -D_DARWIN_USE_64_BIT_INODE 19 | OSXFUSE_CFLAGS += -O -g -Wall 20 | 21 | CFLAGS := $(OSXFUSE_CFLAGS) $(CFLAGS) 22 | CXXFLAGS:= $(OSXFUSE_CFLAGS) $(CXXFLAGS) 23 | LDFLAGS=-L$(LIBRARY_DIR) -losxfuse -framework Carbon 24 | 25 | # Configure this depending on where you installed pcrecpp 26 | # http://www.pcre.org 27 | 28 | PCRECPP_PREFIX=$(shell pcre-config --prefix) 29 | 30 | PCRECPP_CXXFLAGS=-I$(PCRECPP_PREFIX)/include 31 | PCRECPP_LDFLAGS=$(PCRECPP_PREFIX)/lib/libpcrecpp.a $(PCRECPP_PREFIX)/lib/libpcre.a 32 | 33 | all: windowfs 34 | 35 | GetPID.o: GetPID.c 36 | $(CC) -c $(CFLAGS) -o $@ $< 37 | 38 | windowfs.o: windowfs.cc 39 | $(CXX) -c $(CXXFLAGS) $(PCRECPP_CXXFLAGS) -fwritable-strings -o $@ $< 40 | 41 | windowfs_windows.o: windowfs_windows.cc windowfs_windows.h 42 | $(CXX) -c $(CXXFLAGS) -o $@ $< 43 | 44 | windowfs: windowfs.o windowfs_windows.o GetPID.o 45 | $(CXX) $(CXXFLAGS) $(PCRECPP_CXXFLAGS) -o $@ $^ $(LDFLAGS) $(PCRECPP_LDFLAGS) 46 | 47 | install: windowfs 48 | sudo chown root:wheel windowfs 49 | sudo chmod u+s windowfs 50 | sudo mv windowfs /usr/local/bin/windowfs 51 | 52 | clean: 53 | rm -f windowfs GetPID.o windowfs.o windowfs_windows.o 54 | -------------------------------------------------------------------------------- /filesystems-c/grabfs/windowfs_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MacFUSE-Based windowfs 3 | * 4 | * Copyright Amit Singh. All Rights Reserved. 5 | * http://osxbook.com 6 | */ 7 | 8 | #ifndef _WINDOWFS_WINDOWS_H_ 9 | #define _WINDOWFS_WINDOWS_H_ 10 | 11 | #include 12 | #include 13 | 14 | extern "C" { 15 | 16 | #define MAX_WINDOWS 256 17 | 18 | typedef mach_port_t CGSConnectionID; 19 | typedef mach_port_t CGSWindowID; 20 | 21 | typedef struct { 22 | pid_t pid; 23 | int windowCount; 24 | CGSWindowID windowIDs[MAX_WINDOWS]; 25 | } WindowListData; 26 | 27 | extern CGSConnectionID _CGSDefaultConnection(void); 28 | extern CGError CGSGetWindowLevel(CGSConnectionID connectionID, 29 | CGSWindowID windowID, CGWindowLevel *level); 30 | extern CGError CGSGetConnectionIDForPSN(CGSConnectionID connectionID, 31 | ProcessSerialNumber *psn, 32 | CGSConnectionID *out); 33 | extern CGError CGSGetOnScreenWindowList(CGSConnectionID connectionID, 34 | CGSConnectionID targetConnectionID, 35 | int maxCount, 36 | CGSWindowID *windowList, 37 | int *outCount); 38 | extern CGError CGSGetWindowList(CGSConnectionID connectionID, 39 | CGSConnectionID targetConnectionID, 40 | int maxCount, 41 | CGSWindowID *windowList, 42 | int *outCount); 43 | extern CGError CGSGetScreenRectForWindow(CGSConnectionID connectionID, 44 | CGSWindowID windowID, CGRect *outRect); 45 | 46 | extern CGError CGSGetParentWindowList(CGSConnectionID connectionID, 47 | CGSConnectionID targetConnectionID, 48 | int maxCount, 49 | CGSWindowID *windowList, 50 | int *outCount); 51 | 52 | int WINDOWFS_GetTIFFForWindowAtIndex(CGWindowID index, CFMutableDataRef *data); 53 | off_t WINDOWFS_GetTIFFSizeForWindowAtIndex(CGWindowID index); 54 | int WINDOWFS_GetWindowList(WindowListData *data); 55 | 56 | struct WINDOWFSWindowData { 57 | CFMutableDataRef window_tiff; 58 | size_t len; 59 | size_t max_len; 60 | }; 61 | 62 | } /* extern "C" */ 63 | 64 | #endif /* _WINDOWFS_WINDOWS_H_ */ 65 | -------------------------------------------------------------------------------- /filesystems-c/hello/.gitignore: -------------------------------------------------------------------------------- 1 | *.dSYM/ 2 | *.a 3 | *.dylib 4 | *.o 5 | 6 | .DS_Store 7 | hello 8 | hello_ll 9 | -------------------------------------------------------------------------------- /filesystems-c/hello/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = hello hello_ll 2 | 3 | # Root for OSXFUSE includes and libraries 4 | OSXFUSE_ROOT = /usr/local 5 | #OSXFUSE_ROOT = /opt/local 6 | 7 | INCLUDE_DIR = $(OSXFUSE_ROOT)/include/osxfuse/fuse 8 | LIBRARY_DIR = $(OSXFUSE_ROOT)/lib 9 | 10 | CC ?= gcc 11 | 12 | CFLAGS_OSXFUSE = -I$(INCLUDE_DIR) -L$(LIBRARY_DIR) 13 | CFLAGS_OSXFUSE += -DFUSE_USE_VERSION=26 14 | CFLAGS_OSXFUSE += -D_FILE_OFFSET_BITS=64 15 | CFLAGS_OSXFUSE += -D_DARWIN_USE_64_BIT_INODE 16 | 17 | CFLAGS_EXTRA = -Wall -g $(CFLAGS) 18 | 19 | LIBS = -losxfuse 20 | 21 | .c: 22 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -o $@ $< $(LIBS) 23 | 24 | all: $(TARGETS) 25 | 26 | hello: hello.c 27 | 28 | hello_ll: hello_ll.c 29 | 30 | clean: 31 | rm -f $(TARGETS) *.o 32 | rm -rf *.dSYM 33 | -------------------------------------------------------------------------------- /filesystems-c/hello/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | static const char *file_path = "/hello.txt"; 7 | static const char file_content[] = "Hello World!\n"; 8 | static const size_t file_size = sizeof(file_content)/sizeof(char) - 1; 9 | 10 | static int 11 | hello_getattr(const char *path, struct stat *stbuf) 12 | { 13 | memset(stbuf, 0, sizeof(struct stat)); 14 | 15 | if (strcmp(path, "/") == 0) { /* The root directory of our file system. */ 16 | stbuf->st_mode = S_IFDIR | 0755; 17 | stbuf->st_nlink = 3; 18 | } else if (strcmp(path, file_path) == 0) { /* The only file we have. */ 19 | stbuf->st_mode = S_IFREG | 0444; 20 | stbuf->st_nlink = 1; 21 | stbuf->st_size = file_size; 22 | } else /* We reject everything else. */ 23 | return -ENOENT; 24 | 25 | return 0; 26 | } 27 | 28 | static int 29 | hello_open(const char *path, struct fuse_file_info *fi) 30 | { 31 | if (strcmp(path, file_path) != 0) /* We only recognize one file. */ 32 | return -ENOENT; 33 | 34 | if ((fi->flags & O_ACCMODE) != O_RDONLY) /* Only reading allowed. */ 35 | return -EACCES; 36 | 37 | return 0; 38 | } 39 | 40 | static int 41 | hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler, 42 | off_t offset, struct fuse_file_info *fi) 43 | { 44 | if (strcmp(path, "/") != 0) /* We only recognize the root directory. */ 45 | return -ENOENT; 46 | 47 | filler(buf, ".", NULL, 0); /* Current directory (.) */ 48 | filler(buf, "..", NULL, 0); /* Parent directory (..) */ 49 | filler(buf, file_path + 1, NULL, 0); /* The only file we have. */ 50 | 51 | return 0; 52 | } 53 | 54 | static int 55 | hello_read(const char *path, char *buf, size_t size, off_t offset, 56 | struct fuse_file_info *fi) 57 | { 58 | if (strcmp(path, file_path) != 0) 59 | return -ENOENT; 60 | 61 | if (offset >= file_size) /* Trying to read past the end of file. */ 62 | return 0; 63 | 64 | if (offset + size > file_size) /* Trim the read to the file size. */ 65 | size = file_size - offset; 66 | 67 | memcpy(buf, file_content + offset, size); /* Provide the content. */ 68 | 69 | return size; 70 | } 71 | 72 | static struct fuse_operations hello_filesystem_operations = { 73 | .getattr = hello_getattr, /* To provide size, permissions, etc. */ 74 | .open = hello_open, /* To enforce read-only access. */ 75 | .read = hello_read, /* To provide file content. */ 76 | .readdir = hello_readdir, /* To provide directory listing. */ 77 | }; 78 | 79 | int 80 | main(int argc, char **argv) 81 | { 82 | return fuse_main(argc, argv, &hello_filesystem_operations, NULL); 83 | } 84 | -------------------------------------------------------------------------------- /filesystems-c/loopback/.gitignore: -------------------------------------------------------------------------------- 1 | *.dSYM/ 2 | *.a 3 | *.dylib 4 | *.o 5 | 6 | .DS_Store 7 | loopback 8 | -------------------------------------------------------------------------------- /filesystems-c/loopback/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = loopback 2 | 3 | # Root for OSXFUSE includes and libraries 4 | OSXFUSE_ROOT = /usr/local 5 | #OSXFUSE_ROOT = /opt/local 6 | 7 | INCLUDE_DIR = $(OSXFUSE_ROOT)/include/osxfuse/fuse 8 | LIBRARY_DIR = $(OSXFUSE_ROOT)/lib 9 | 10 | CC ?= gcc 11 | 12 | CFLAGS_OSXFUSE = -I$(INCLUDE_DIR) -L$(LIBRARY_DIR) 13 | CFLAGS_OSXFUSE += -D_FILE_OFFSET_BITS=64 14 | CFLAGS_OSXFUSE += -D_DARWIN_USE_64_BIT_INODE 15 | 16 | CFLAGS_EXTRA = -Wall -g $(CFLAGS) 17 | 18 | LIBS = -losxfuse 19 | 20 | .c: 21 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -o $@ $< $(LIBS) 22 | 23 | all: info 24 | 25 | loopback: loopback.c 26 | 27 | info: $(TARGETS) 28 | @echo 29 | @echo Compiled. The following is a typical way to run the loopback file system. In 30 | @echo this example, /tmp/dir is an existing directory whose contents will become 31 | @echo available in the existing mount point /Volumes/loop: 32 | @echo 33 | @echo "sudo ./loopback /Volumes/loop -omodules=threadid:subdir,subdir=/tmp/dir -oallow_other,native_xattr,volname=LoopbackFS" 34 | @echo 35 | 36 | clean: 37 | rm -f $(TARGETS) *.o 38 | rm -rf *.dSYM 39 | -------------------------------------------------------------------------------- /filesystems-c/procfs/.gitignore: -------------------------------------------------------------------------------- 1 | *.dSYM/ 2 | *.a 3 | *.dylib 4 | *.o 5 | 6 | .DS_Store 7 | procfs 8 | -------------------------------------------------------------------------------- /filesystems-c/procfs/Makefile: -------------------------------------------------------------------------------- 1 | # procfs as a OSXFUSE file system for Mac OS X 2 | # 3 | # Copyright 2007 Amit Singh (osxbook.com). All Rights Reserved. 4 | 5 | CC ?= gcc 6 | CXX ?= g++ 7 | 8 | CFLAGS_OSXFUSE=-D_FILE_OFFSET_BITS=64 -O -g -I/usr/local/include/osxfuse -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -Wall 9 | CFLAGS :=$(CFLAGS_OSXFUSE) $(CFLAGS) 10 | CXXFLAGS:=$(CFLAGS_OSXFUSE) $(CXXFLAGS) 11 | LDFLAGS=-L/usr/local/lib -losxfuse -framework Carbon -framework IOKit -framework ApplicationServices -framework Accelerate -framework OpenGL -weak-lproc 12 | SEQUENCEGRAB_LDFLAGS=-framework AudioUnit -framework Cocoa -framework CoreAudioKit -framework Foundation -framework QuartzCore -framework QuickTime -framework QuartzCore 13 | 14 | # Configure this depending on where you installed pcrecpp 15 | # http://www.pcre.org 16 | # 17 | PCRECPP_PREFIX=$(shell pcre-config --prefix) 18 | 19 | PCRECPP_CXXFLAGS=-I$(PCRECPP_PREFIX)/include 20 | PCRECPP_LDFLAGS=-arch i386 $(PCRECPP_PREFIX)/lib/libpcrecpp.a $(PCRECPP_PREFIX)/lib/libpcre.a 21 | 22 | all: procfs 23 | 24 | procfs.o: procfs.cc 25 | $(CXX) -c $(CXXFLAGS) $(PCRECPP_CXXFLAGS) -o $@ $< 26 | 27 | procfs_displays.o: procfs_displays.cc procfs_displays.h 28 | $(CXX) -c $(CXXFLAGS) -o $@ $< 29 | 30 | procfs_proc_info.o: procfs_proc_info.cc procfs_proc_info.h 31 | $(CXX) -c $(CXXFLAGS) -o $@ $< 32 | 33 | procfs_tpm.o: procfs_tpm.cc procfs_tpm.h 34 | $(CXX) -c $(CXXFLAGS) -o $@ $< 35 | 36 | procfs_windows.o: procfs_windows.cc procfs_windows.h 37 | $(CXX) -c $(CXXFLAGS) -o $@ $< 38 | 39 | procfs: procfs.o procfs_displays.o procfs_proc_info.o procfs_tpm.o procfs_windows.o sequencegrab/libprocfs_sequencegrab.a 40 | $(CXX) $(CXXFLAGS) $(PCRECPP_CXXFLAGS) -o $@ $^ $(LDFLAGS) $(PCRECPP_LDFLAGS) $(SEQUENCEGRAB_LDFLAGS) 41 | 42 | sequencegrab/libprocfs_sequencegrab.a: 43 | $(MAKE) -C sequencegrab 44 | 45 | install: procfs 46 | sudo chown root:wheel procfs 47 | sudo chmod u+s procfs 48 | sudo mv procfs /usr/local/bin/procfs 49 | 50 | clean: 51 | rm -f procfs procfs.o procfs_displays.o procfs_proc_info.o procfs_tpm.o procfs_windows.o 52 | $(MAKE) -C sequencegrab clean 53 | -------------------------------------------------------------------------------- /filesystems-c/procfs/README: -------------------------------------------------------------------------------- 1 | System Requirements 2 | =================== 3 | 4 | * Mac OS X 10.5+ (10.4 is no longer supported) 5 | 6 | * pcre (specifically, the C++ wrapper for pcre) 7 | 8 | ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 9 | 10 | Usage 11 | ===== 12 | 13 | You can mount procfs as: 14 | 15 | $ sudo mkdir /proc 16 | $ sudo chown root:admin /proc 17 | $ sudo ./procfs /proc -f 18 | 19 | For certain things to work (and not crash procfs), you must either run 20 | procfs foregrounded (through the -f option), or use the procfs.plist 21 | file to run procfs through launchd. 22 | -------------------------------------------------------------------------------- /filesystems-c/procfs/procfs.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | com.osxbook.procfs 7 | ProgramArguments 8 | 9 | /usr/local/bin/procfs 10 | /proc 11 | -f 12 | 13 | KeepAlive 14 | 15 | UserName 16 | root 17 | WorkingDirectory 18 | / 19 | 20 | 21 | -------------------------------------------------------------------------------- /filesystems-c/procfs/procfs_displays.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MacFUSE-Based procfs 3 | */ 4 | 5 | #ifndef _PROCFS_DISPLAYS_H_ 6 | #define _PROCFS_DISPLAYS_H_ 7 | 8 | #include 9 | #include 10 | 11 | extern "C" { 12 | 13 | CGDisplayCount PROCFS_GetDisplayCount(void); 14 | int PROCFS_GetInfoForDisplayAtIndex(unsigned int index, char *buf, 15 | size_t *size); 16 | int PROCFS_GetPNGForDisplayAtIndex(unsigned int index, CFMutableDataRef *data); 17 | off_t PROCFS_GetPNGSizeForDisplayAtIndex(unsigned int index); 18 | 19 | } /* extern "C" */ 20 | 21 | #endif /* _PROCFS_DISPLAYS_H_ */ 22 | -------------------------------------------------------------------------------- /filesystems-c/procfs/procfs_proc_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * procfs as a MacFUSE file system for Mac OS X 3 | * 4 | * Copyright Amit Singh. All Rights Reserved. 5 | * http://osxbook.com 6 | * 7 | * http://code.google.com/p/macfuse/ 8 | * 9 | * Source License: GNU GENERAL PUBLIC LICENSE (GPL) 10 | */ 11 | 12 | #ifndef _LOCAL_SYS_PROC_INFO_H 13 | #define _LOCAL_SYS_PROC_INFO_H 14 | 15 | extern "C" { 16 | 17 | __BEGIN_DECLS 18 | 19 | #include 20 | 21 | extern int procfs_proc_pidinfo(pid_t pid, char *buf, int *len); 22 | 23 | __END_DECLS 24 | 25 | } 26 | 27 | #endif /*_LOCAL_SYS_PROC_INFO_H */ 28 | -------------------------------------------------------------------------------- /filesystems-c/procfs/procfs_tpm.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2003 IBM 3 | * Source License: GNU GENERAL PUBLIC LICENSE (GPL) 4 | */ 5 | 6 | /* 7 | * OSXFUSE-Based procfs 8 | * TPM Files 9 | */ 10 | 11 | extern "C" { 12 | 13 | #if OSXFUSE_PROCFS_ENABLE_TPM 14 | 15 | #include "procfs_tpm.h" 16 | 17 | uint32_t 18 | TPM_GetCapability_Version(int *major, int *minor, int *version, int *rev) 19 | { 20 | unsigned char blob[4096] = { 21 | 0, 193, /* TPM_TAG_RQU_COMMAND */ 22 | 0, 0, 0, 18, /* blob length, bytes */ 23 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ 24 | 0, 0, 0, 6, /* TCPA_CAP_VERSION */ 25 | 0, 0, 0, 0 /* no sub capability */ 26 | }; 27 | uint32_t ret; 28 | ret = TPM_Transmit(blob, "TPM_GetCapability_Version"); 29 | if (ret) 30 | return (ret); 31 | *major = (int) (blob[14]); 32 | *minor = (int) (blob[15]); 33 | *version = (int) (blob[16]); 34 | *rev = (int) (blob[17]); 35 | return (ret); 36 | } 37 | 38 | uint32_t 39 | TPM_GetCapability_Slots(uint32_t * slots) 40 | { 41 | unsigned char blob[4096] = { 42 | 0, 193, /* TPM_TAG_RQU_COMMAND */ 43 | 0, 0, 0, 22, /* blob length, bytes */ 44 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ 45 | 0, 0, 0, 5, /* TCPA_CAP_PROPERTY */ 46 | 0, 0, 0, 4, /* SUB_CAP size, bytes */ 47 | 0, 0, 1, 4 /* TCPA_CAP_PROP_SLOTS */ 48 | }; 49 | uint32_t ret; 50 | ret = TPM_Transmit(blob, "TPM_GetCapability_Slots"); 51 | if (ret) 52 | return (ret); 53 | *slots = ntohl(*(uint32_t *) (blob + 14)); 54 | return (ret); 55 | } 56 | 57 | uint32_t 58 | TPM_GetCapability_Pcrs(uint32_t * pcrs) 59 | { 60 | unsigned char blob[4096] = { 61 | 0, 193, /* TPM_TAG_RQU_COMMAND */ 62 | 0, 0, 0, 22, /* blob length, bytes */ 63 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ 64 | 0, 0, 0, 5, /* TCPA_CAP_PROPERTY */ 65 | 0, 0, 0, 4, /* SUB_CAP size, bytes */ 66 | 0, 0, 1, 1 /* TCPA_CAP_PROP_PCR */ 67 | }; 68 | uint32_t ret; 69 | ret = TPM_Transmit(blob, "TPM_GetCapability_Pcrs"); 70 | if (ret) 71 | return (ret); 72 | *pcrs = ntohl(*(uint32_t *) (blob + 14)); 73 | return (ret); 74 | } 75 | 76 | uint32_t 77 | TPM_GetCapability_Key_Handle(uint16_t * num, uint32_t keys[]) 78 | { 79 | unsigned char blob[4096] = { 80 | 0, 193, /* TPM_TAG_RQU_COMMAND */ 81 | 0, 0, 0, 18, /* blob length, bytes */ 82 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ 83 | 0, 0, 0, 7, /* TCPA_CAP_KEY_HANDLE */ 84 | 0, 0, 0, 0 /* no sub capability */ 85 | }; 86 | uint32_t ret; 87 | int i; 88 | ret = TPM_Transmit(blob, "TPM_GetCapability_Handle_List"); 89 | if (ret) 90 | return (ret); 91 | *num = ntohs(*(uint16_t *) (blob + 14)); 92 | for (i = 0; i < *num; i++) 93 | keys[i] = ntohl(*(uint32_t *) (blob + 16 + 4 * i)); 94 | return (ret); 95 | } 96 | 97 | #endif /* OSXFUSE_PROCFS_ENABLE_TPM */ 98 | 99 | } 100 | -------------------------------------------------------------------------------- /filesystems-c/procfs/procfs_tpm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2003 IBM 3 | * Source License: GNU GENERAL PUBLIC LICENSE (GPL) 4 | */ 5 | 6 | /* 7 | * OSXFUSE-Based procfs 8 | */ 9 | 10 | #ifndef _PROCFS_TPM_H_ 11 | #define _PROCFS_TPM_H_ 12 | 13 | #include 14 | #include 15 | 16 | uint32_t 17 | TPM_GetCapability_Version(int *major, int *minor, int *version, int *rev); 18 | 19 | uint32_t 20 | TPM_GetCapability_Slots(uint32_t *slots); 21 | 22 | uint32_t 23 | TPM_GetCapability_Pcrs(uint32_t *pcrs); 24 | 25 | uint32_t 26 | TPM_GetCapability_Key_Handle(uint16_t *num, uint32_t keys[]); 27 | 28 | #endif /* _PROCFS_TPM_H_ */ 29 | -------------------------------------------------------------------------------- /filesystems-c/procfs/procfs_windows.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * MacFUSE-Based procfs 3 | * Windows 4 | * 5 | */ 6 | 7 | #include 8 | 9 | extern "C" { 10 | 11 | #include "procfs_windows.h" 12 | 13 | off_t 14 | PROCFS_GetPNGSizeForWindowAtIndex(CGWindowID index) 15 | { 16 | CGRect rect; 17 | 18 | CGError err = CGSGetScreenRectForWindow(_CGSDefaultConnection(), index, 19 | &rect); 20 | if (err) { 21 | return (off_t)0; 22 | } 23 | 24 | off_t size = ((off_t)rect.size.width * (off_t)rect.size.height * (off_t)3) 25 | + (off_t)8192; 26 | 27 | return size; 28 | } 29 | 30 | int 31 | PROCFS_GetPNGForWindowAtIndex(CGWindowID index, CFMutableDataRef *data) 32 | { 33 | *data = (CFMutableDataRef)0; 34 | 35 | CGImageRef image = CGWindowListCreateImage( 36 | CGRectNull, kCGWindowListOptionIncludingWindow, 37 | index, kCGWindowImageBoundsIgnoreFraming); 38 | 39 | if (!image) { 40 | return -1; 41 | } 42 | 43 | *data = CFDataCreateMutable(kCFAllocatorDefault, 0); 44 | if (!*data) { 45 | CFRelease(image); 46 | return -1; 47 | } 48 | 49 | CGImageDestinationRef dest = 50 | CGImageDestinationCreateWithData((CFMutableDataRef)*data, kUTTypePNG, 51 | 1, nil); 52 | if (!dest) { 53 | CFRelease(*data); 54 | CFRelease(image); 55 | return -1; 56 | } 57 | 58 | CGImageDestinationAddImage(dest, image, nil); 59 | CGImageDestinationFinalize(dest); 60 | 61 | CFRelease(dest); 62 | CGImageRelease(image); 63 | 64 | return 0; 65 | } 66 | 67 | } /* extern "C" */ 68 | -------------------------------------------------------------------------------- /filesystems-c/procfs/procfs_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MacFUSE-Based procfs 3 | */ 4 | 5 | #ifndef _PROCFS_WINDOWS_H_ 6 | #define _PROCFS_WINDOWS_H_ 7 | 8 | #include 9 | #include 10 | 11 | extern "C" { 12 | 13 | typedef mach_port_t CGSConnectionID; 14 | typedef mach_port_t CGSWindowID; 15 | 16 | extern CGSConnectionID _CGSDefaultConnection(void); 17 | extern CGError CGSGetWindowLevel(CGSConnectionID connectionID, 18 | CGSWindowID windowID, CGWindowLevel *level); 19 | extern CGError CGSGetConnectionIDForPSN(CGSConnectionID connectionID, 20 | ProcessSerialNumber *psn, 21 | CGSConnectionID *out); 22 | extern CGError CGSGetOnScreenWindowList(CGSConnectionID connectionID, 23 | CGSConnectionID targetConnectionID, 24 | int maxCount, 25 | CGSWindowID *windowList, 26 | int *outCount); 27 | extern CGError CGSGetWindowList(CGSConnectionID connectionID, 28 | CGSConnectionID targetConnectionID, 29 | int maxCount, 30 | CGSWindowID *windowList, 31 | int *outCount); 32 | extern CGError CGSGetScreenRectForWindow(CGSConnectionID connectionID, 33 | CGSWindowID windowID, CGRect *outRect); 34 | 35 | extern CGError CGSGetParentWindowList(CGSConnectionID connectionID, 36 | CGSConnectionID targetConnectionID, 37 | int maxCount, 38 | CGSWindowID *windowList, 39 | int *outCount); 40 | 41 | int PROCFS_GetPNGForWindowAtIndex(CGWindowID index, CFMutableDataRef *data); 42 | off_t PROCFS_GetPNGSizeForWindowAtIndex(CGWindowID index); 43 | 44 | struct ProcfsWindowData { 45 | CFMutableDataRef window_png; 46 | size_t len; 47 | size_t max_len; 48 | }; 49 | 50 | } /* extern "C" */ 51 | 52 | #endif /* _PROCFS_WINDOWS_H_ */ 53 | -------------------------------------------------------------------------------- /filesystems-c/procfs/sequencegrab/CSGCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // CSGCamera.h 3 | // MotionTracker 4 | // 5 | // Created by Tim Omernick on 3/7/05. 6 | // Copyright 2005 Tim Omernick. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class CSGImage; 13 | 14 | /* 15 | CSGCamera provides a simple way to access the default sequence grabber component (say, an iSight or other DV camera). To use: 16 | 17 | - Instantiate an CSGCamera instance (using the plain old -init method) 18 | - Set the CSGCamera's delegate using -setDelegate:. The delegate is the object which will receive -camera:didReceiveFrame: messages. 19 | - Call -startWithSize: on the CSGCamera instance with a decent size (like 512x384). 20 | - Call -stop to stop recording. 21 | */ 22 | 23 | @interface CSGCamera : NSObject 24 | { 25 | id delegate; 26 | SeqGrabComponent component; 27 | SGChannel channel; 28 | GWorldPtr gWorld; 29 | Rect boundsRect; 30 | ImageSequence decompressionSequence; 31 | TimeScale timeScale; 32 | TimeValue lastTime; 33 | NSTimeInterval startTime; 34 | NSTimer *frameTimer; 35 | } 36 | 37 | - (void)setDelegate:(id)newDelegate; 38 | - (BOOL)startWithSize:(NSSize)frameSize; 39 | - (BOOL)stop; 40 | 41 | @end 42 | 43 | @interface NSObject (Private) 44 | - (void)camera:(CSGCamera *)aCamera didReceiveFrame:(CSGImage *)aFrame; 45 | @end 46 | -------------------------------------------------------------------------------- /filesystems-c/procfs/sequencegrab/CSGImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // CSGImage.h 3 | // MotionTracker 4 | // 5 | // Created by Tim Omernick on 3/6/05. 6 | // Copyright 2005 Tim Omernick. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CSGImage : NSImage 12 | { 13 | NSTimeInterval sampleTime; 14 | } 15 | 16 | - (NSTimeInterval)sampleTime; 17 | - (void)setSampleTime:(NSTimeInterval)newSampleTime; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /filesystems-c/procfs/sequencegrab/CSGImage.m: -------------------------------------------------------------------------------- 1 | // 2 | // CSGImage.m 3 | // MotionTracker 4 | // 5 | // Created by Tim Omernick on 3/6/05. 6 | // Copyright 2005 Tim Omernick. All rights reserved. 7 | // 8 | 9 | #import "CSGImage.h" 10 | 11 | @implementation CSGImage 12 | 13 | // NSObject subclass 14 | 15 | - (NSString *)description; 16 | { 17 | return [NSString stringWithFormat:@"<%@: %p> (sampleTime=%.4f)", NSStringFromClass([self class]), self, sampleTime]; 18 | } 19 | 20 | // API 21 | 22 | - (NSTimeInterval)sampleTime; 23 | { 24 | return sampleTime; 25 | } 26 | 27 | - (void)setSampleTime:(NSTimeInterval)newSampleTime; 28 | { 29 | sampleTime = newSampleTime; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /filesystems-c/procfs/sequencegrab/CocoaSequenceGrabber.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CocoaSequenceGrabber.h 3 | * CocoaSequenceGrabber 4 | * 5 | * Created by Tim Omernick on 3/18/05. 6 | * Copyright 2005 Tim Omernick. All rights reserved. 7 | * 8 | */ 9 | 10 | #import 11 | #import "CSGCamera.h" 12 | #import "CSGImage.h" 13 | -------------------------------------------------------------------------------- /filesystems-c/procfs/sequencegrab/Makefile: -------------------------------------------------------------------------------- 1 | # Sequence Grabbing Library 2 | # 3 | # Dave MacLachlan 4 | 5 | CC ?= gcc 6 | CXX ?= g++ 7 | CFLAGS := -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk $(CFLAGS) 8 | CXXFLAGS := -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk $(CXXFLAGS) 9 | LDFLAGS = -framework Cocoa -framework CoreAudioKit -framework Foundation -framework QuartzCore -framework QuickTime -framework QuartzCore 10 | 11 | OBJECTS = CSGCamera.o CSGImage.o procfs_sequencegrab.o 12 | 13 | all: libprocfs_sequencegrab.dylib libprocfs_sequencegrab.a 14 | 15 | %o.%m: 16 | $(CC) -c $(CFLAGS) -o $@ $< 17 | 18 | CSGCamera.o: CSGCamera.m 19 | CSGImage.o: CSGImage.m 20 | 21 | procfs_sequencegrab.o: procfs_sequencegrab.mm 22 | $(CXX) -c $(CXXFLAGS) -o $@ $< 23 | 24 | libprocfs_sequencegrab.dylib: $(OBJECTS) 25 | $(CXX) -dynamiclib -install_name /usr/local/lib/libprocfs_sequencegrab.dylib $(CXXFLAGS) -o $@ $(OBJECTS) $(LDFLAGS) 26 | 27 | libprocfs_sequencegrab.a: $(OBJECTS) 28 | libtool -static -o libprocfs_sequencegrab.a $(OBJECTS) 29 | ranlib libprocfs_sequencegrab.a 30 | 31 | clean: 32 | rm -f *.o libprocfs_sequencegrab.dylib libprocfs_sequencegrab.a 33 | -------------------------------------------------------------------------------- /filesystems-c/procfs/sequencegrab/procfs_sequencegrab.h: -------------------------------------------------------------------------------- 1 | #ifndef _PROCFS_SEQUENCEGRAB_H_ 2 | #define _PROCFS_SEQUENCEGRAB_H_ 3 | 4 | #include 5 | 6 | #define CAMERA_TRIGGER_THRESHOLD 4 7 | #define CAMERA_ACTIVE_DURATION 1 8 | 9 | int PROCFS_GetTIFFFromCamera(CFMutableDataRef *data); 10 | off_t PROCFS_GetTIFFSizeFromCamera(void); 11 | 12 | #endif /* _PROCFS_SEQUENCEGRAB_H_ */ 13 | -------------------------------------------------------------------------------- /filesystems-c/procfs/sequencegrab/procfs_sequencegrab.mm: -------------------------------------------------------------------------------- 1 | #import "procfs_sequencegrab.h" 2 | #import "CocoaSequenceGrabber.h" 3 | 4 | static int loopCount = 0; 5 | 6 | @interface Snapshot : CSGCamera 7 | { 8 | CFMutableDataRef tiff; 9 | } 10 | 11 | - (void)setDataRef:(CFMutableDataRef)dataRef; 12 | - (void)camera:(CSGCamera *)aCamera didReceiveFrame:(CSGImage *)aFrame; 13 | 14 | @end 15 | 16 | @implementation Snapshot 17 | 18 | - (void)setDataRef:(CFMutableDataRef)dataRef 19 | { 20 | tiff = dataRef; 21 | } 22 | 23 | - (void)camera:(CSGCamera *)aCamera didReceiveFrame:(CSGImage *)aFrame; 24 | { 25 | if (++loopCount == CAMERA_TRIGGER_THRESHOLD) { 26 | CFDataRef image = (CFDataRef)[aFrame TIFFRepresentationUsingCompression:NSTIFFCompressionNone factor:0.0]; 27 | CFIndex len = CFDataGetLength(image); 28 | CFDataSetLength(tiff, len); 29 | CFDataReplaceBytes(tiff, CFRangeMake((CFIndex)0, len), CFDataGetBytePtr(image), len); 30 | //CFRelease(image); 31 | [self stop]; 32 | } 33 | } 34 | 35 | @end 36 | 37 | off_t 38 | PROCFS_GetTIFFSizeFromCamera(void) 39 | { 40 | return (off_t)((off_t)(640 * 480 * 4) + (off_t)8192); 41 | } 42 | 43 | int 44 | PROCFS_GetTIFFFromCamera(CFMutableDataRef *data) 45 | { 46 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 47 | 48 | loopCount = 0; 49 | 50 | Snapshot *camera = [[Snapshot alloc] init]; 51 | [camera setDataRef:*data]; 52 | [camera setDelegate:camera]; 53 | [camera startWithSize:NSMakeSize(640, 480)]; 54 | [[NSRunLoop currentRunLoop] 55 | runUntilDate:[NSDate dateWithTimeIntervalSinceNow:CAMERA_ACTIVE_DURATION]]; 56 | [camera release]; 57 | 58 | [pool release]; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/.gitignore: -------------------------------------------------------------------------------- 1 | *.dSYM/ 2 | *.a 3 | *.d 4 | *.dylib 5 | *.o 6 | 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/Makefile: -------------------------------------------------------------------------------- 1 | DIRS = ancientfs minixfs sysvfs ufs 2 | 3 | all: 4 | -for dir in $(DIRS); do $(MAKE) -C $$dir; done 5 | 6 | clean: 7 | -for dir in $(DIRS); do $(MAKE) -C $$dir clean; done 8 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/.gitignore: -------------------------------------------------------------------------------- 1 | ancientfs 2 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/AncientUnix.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/ancientfs/AncientUnix.pdf -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | AncientFS is Copyright (c) 2008 Amit Singh. All Rights Reserved. 2 | 3 | For licensing and copyright information on 16-bit UNIX Versions 1, 2, 3, 4, 4 | 5, 6, 7, and 32-bit 32V UNIX, see the accompanying file AncientUnix.pdf or 5 | read it online at: 6 | 7 | http://www.tuhs.org/Archive/Caldera-license.pdf 8 | 9 | Code in ancient BSDs is covered by the Berkeley software License Agreement: 10 | 11 | /* 12 | * Copyright (c) 1986 Regents of the University of California. 13 | * All rights reserved. The Berkeley software License Agreement 14 | * specifies the terms and conditions for redistribution. 15 | * 16 | */ 17 | 18 | UNIX(R) is a registered trademark of The Open Group 19 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/Makefile: -------------------------------------------------------------------------------- 1 | # Ancient Unix File Systems for Mac OS X 2 | # 3 | # Copyright 2008 Amit Singh (osxbook.com). All Rights Reserved. 4 | 5 | TARGETS = ancientfs 6 | 7 | COMMON=../common 8 | OSNAME=$(shell uname) 9 | UNIXFS=$(COMMON)/unixfs 10 | 11 | ifeq ($(OSNAME), Darwin) 12 | CC ?= gcc 13 | CFLAGS_OSXFUSE = -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=27 -I/usr/local/include/osxfuse -I$(UNIXFS) 14 | CFLAGS_EXTRA = -Wall -Werror -g $(CFLAGS) 15 | LIBS = -losxfuse 16 | endif 17 | 18 | ifeq ($(OSNAME), FreeBSD) 19 | CC ?= gcc 20 | CFLAGS_OSXFUSE = -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=27 -I/usr/local/include -I$(UNIXFS) 21 | CFLAGS_EXTRA = -Wall -Werror -g -rdynamic $(CFLAGS) 22 | LIBS = -L/usr/local/lib -lfuse 23 | endif 24 | 25 | ifeq ($(OSNAME), Linux) 26 | CC ?= gcc 27 | CFLAGS_OSXFUSE = -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=27 -I$(COMMON) -I$(UNIXFS) 28 | CFLAGS_EXTRA = -Wall -Werror -g -rdynamic $(CFLAGS) 29 | LIBS = -lfuse -ldl 30 | endif 31 | 32 | CC ?= false 33 | 34 | all: $(TARGETS) 35 | 36 | OBJS = ancientfs_tap.o ancientfs_tp.o ancientfs_itp.o ancientfs_dtp.o ancientfs_dump.o ancientfs_dump1024.o ancientfs_dumpvn.o ancientfs_dumpvn1024.o ancientfs_voar.o ancientfs_oar.o ancientfs_ar.o ancientfs_bcpio.o ancientfs_cpio_odc.o ancientfs_cpio_newc.o ancientfs_tar.o ancientfs_v1,2,3.o ancientfs_v4,5,6.o ancientfs_v7.o ancientfs_v10.o ancientfs_32v.o ancientfs_2.9bsd.o ancientfs_2.11bsd.o ancientfs_mainx.o 37 | OBJS_COMMON = $(UNIXFS)/unixfs.o $(UNIXFS)/unixfs_internal.o 38 | 39 | ancientfs: $(OBJS) $(OBJS_COMMON) 40 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -o $@ $^ $(LIBS) 41 | 42 | -include $(OBJS:.o=.d) 43 | 44 | %.o: %.c 45 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) $*.c -c -o $*.o 46 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -MM $*.c > $*.d 47 | @mv -f $*.d $*.d.tmp 48 | @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d 49 | @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d 50 | @rm -f $*.d.tmp 51 | 52 | clean: 53 | rm -f $(TARGETS) *.o *.d $(UNIXFS)/*.o $(UNIXFS)/*.d 54 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_H_ 8 | #define _ANCIENTFS_H_ 9 | 10 | /* only upper-half bits */ 11 | 12 | #define ANCIENTFS_UNIX_V1 0x80000000 13 | #define ANCIENTFS_UNIX_V2 0x40000000 14 | #define ANCIENTFS_UNIX_V3 0x20000000 15 | #define ANCIENTFS_UNIX_V4 0x10000000 16 | #define ANCIENTFS_UNIX_V5 0x08000000 17 | #define ANCIENTFS_UNIX_V6 0x04000000 18 | #define ANCIENTFS_UNIX_V10 0x02000000 19 | #define ANCIENTFS_GENTAPE 0x01000000 20 | #define ANCIENTFS_DECTAPE 0x00800000 21 | #define ANCIENTFS_MAGTAPE 0x00400000 22 | #define ANCIENTFS_DUMP1KB 0x00200000 23 | #define ANCIENTFS_VERYOLDAR 0x00100000 24 | #define ANCIENTFS_V7TAR 0x00080000 25 | #define ANCIENTFS_USTAR 0x00040000 26 | #define ANCIENTFS_NEWCRC 0x00020000 27 | 28 | #define TAPEDIR_BEGIN_BLOCK_GENERIC 1 29 | #define TAPEDIR_END_BLOCK_GENERIC (1024*1024) 30 | 31 | /* 32 | * Block zero of the tape is not used. It is available as a boot program to 33 | * be used in a standalone environment. For example, it was used for DEC 34 | * diagnostic programs. 35 | * 36 | * Blocks 1 through 24 contain a directory of the tape. There are 192 entries 37 | * in the directory; 8 entries per block; 64 bytes per entry. We can think of 38 | * such an entry the tape's "dinode". 39 | */ 40 | #define TAPEDIR_BEGIN_BLOCK_DEC 1 41 | #define TAPEDIR_END_BLOCK_DEC 24 42 | 43 | /* 44 | * In the case of magtape, the directory blocks go from 1 through 62. It has 45 | * 496 entries. 46 | */ 47 | #define TAPEDIR_BEGIN_BLOCK_MAG 1 48 | #define TAPEDIR_END_BLOCK_MAG 62 49 | 50 | #endif /* _ANCIENTFS_H_ */ 51 | 52 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_ar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_AR_H_ 8 | #define _ANCIENTFS_AR_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | #define BSIZE 512 14 | #define ROOTINO 1 15 | 16 | struct filsys 17 | { 18 | uint32_t s_fsize; 19 | uint32_t s_files; 20 | uint32_t s_directories; 21 | uint32_t s_lastino; 22 | struct inode* s_rootip; 23 | }; 24 | 25 | #define ARMAG "!\n" /* ar "magic number" */ 26 | #define SARMAG 8 /* strlen(ARMAG); */ 27 | 28 | #define AR_EFMT1 "#1/" /* extended format #1 */ 29 | 30 | struct ar_hdr 31 | { 32 | char ar_name[16]; /* ASCII name */ 33 | char ar_date[12]; /* ASCII modification time */ 34 | char ar_uid[6]; /* ASCII user id */ 35 | char ar_gid[6]; /* ASCII group id */ 36 | char ar_mode[8]; /* ASCII octal file permissions */ 37 | char ar_size[10]; /* ASCII size in bytes */ 38 | #define ARFMAG "`\n" 39 | char ar_fmag[2]; /* ASCII consistency check */ 40 | }; 41 | 42 | struct ar_node_info 43 | { 44 | struct inode* ar_self; 45 | struct ar_node_info* ar_parent; 46 | struct ar_node_info* ar_children; 47 | struct ar_node_info* ar_next_sibling; 48 | char* ar_name; 49 | uint32_t ar_namelen; 50 | }; 51 | 52 | #endif /* _ANCIENTFS_AR_H_ */ 53 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_bcpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_BCPIO_H_ 8 | #define _ANCIENTFS_BCPIO_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | typedef int16_t a_short; /* ancient short */ 14 | typedef uint16_t a_ushort; /* ancient unsigned short */ 15 | typedef int16_t a_int; /* ancient int */ 16 | typedef uint16_t a_uint; /* ancient unsigned int */ 17 | typedef int32_t a_long; /* ancient long */ 18 | typedef uint32_t a_ulong; /* ancient unsigned long */ 19 | 20 | typedef a_uint a_ino_t; /* ancient inode type (ancient unsigned int) */ 21 | typedef a_long a_off_t; /* ancient offset type (ancient long) */ 22 | typedef a_ulong a_time_t; /* ancient time type (ancient long) */ 23 | typedef a_long a_daddr_t; /* ancient disk address type (ancient long) */ 24 | typedef a_int a_dev_t; /* ancient device type (ancient int) */ 25 | 26 | #define ROOTINO 1 27 | 28 | struct filsys 29 | { 30 | uint32_t s_fsize; 31 | uint32_t s_files; 32 | uint32_t s_directories; 33 | uint32_t s_lastino; 34 | uint32_t s_dataoffset; 35 | uint32_t s_needsswap; 36 | struct inode* s_rootip; 37 | }; 38 | 39 | #define BCBLOCK 512 40 | #define BCPIO_MAGIC 070707 41 | #define BCPIO_TRAILER "TRAILER!!!" 42 | #define BCPIO_TRAILER_LEN (sizeof(BCPIO_TRAILER)/sizeof(unsigned char)) 43 | 44 | struct bcpio_header { 45 | a_uint h_magic; 46 | a_uint h_dev; 47 | a_uint h_ino; 48 | a_uint h_mode; 49 | a_uint h_uid; 50 | a_uint h_gid; 51 | a_uint h_nlink; 52 | a_uint h_majmin; 53 | a_int h_mtime_msb16; 54 | a_int h_mtime_lsb16; 55 | a_uint h_namesize; 56 | a_uint h_filesize_msb16; 57 | a_uint h_filesize_lsb16; 58 | /* char h_name[h_namesize rounded to word]; */ 59 | /* char h_data[h_filesize rounded to word]; */ 60 | } __attribute__((packed)); 61 | 62 | struct bcpio_node_info { 63 | struct inode* ci_self; 64 | struct bcpio_node_info* ci_parent; 65 | struct bcpio_node_info* ci_children; 66 | struct bcpio_node_info* ci_next_sibling; 67 | char* ci_name; 68 | char* ci_linktargetname; 69 | }; 70 | 71 | /* modes */ 72 | #define IALLOC 0100000 /* i-node is allocated */ 73 | #define ILARG 010000 /* large file */ 74 | #define IFMT 0170000 /* type of file */ 75 | 76 | static inline mode_t 77 | ancientfs_bcpio_mode(mode_t mode, uint32_t flags) 78 | { 79 | return mode & (uint16_t)~(IALLOC & ILARG); 80 | } 81 | 82 | #endif /* _ANCIENTFS_BCPIO_H_ */ 83 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_cpio_newc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_CPIO_NEWC_H_ 8 | #define _ANCIENTFS_CPIO_NEWC_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | #define ROOTINO 1 14 | 15 | struct filsys 16 | { 17 | uint32_t s_fsize; 18 | uint32_t s_files; 19 | uint32_t s_directories; 20 | uint32_t s_lastino; 21 | uint32_t s_dataoffset; 22 | uint32_t s_needsswap; 23 | struct inode* s_rootip; 24 | }; 25 | 26 | #define CPIO_NEWC_BLOCK 512 27 | #define CPIO_NEWC_MAGIC "070701" 28 | #define CPIO_NEWCRC_MAGIC "070702" 29 | #define CPIO_NEWC_MAGLEN 6 30 | #define CPIO_NEWC_TRAILER "TRAILER!!!" 31 | #define CPIO_NEWC_TRAILER_LEN (sizeof(CPIO_NEWC_TRAILER)/sizeof(unsigned char)) 32 | 33 | struct cpio_newc_header { 34 | char c_magic[6]; 35 | char c_ino[8]; 36 | char c_mode[8]; 37 | char c_uid[8]; 38 | char c_gid[8]; 39 | char c_nlink[8]; 40 | char c_mtime[8]; 41 | char c_filesize[8]; 42 | char c_devmajor[8]; 43 | char c_devminor[8]; 44 | char c_rdevmajor[8]; 45 | char c_rdevminor[8]; 46 | char c_namesize[8]; 47 | char c_check[8]; 48 | /* char c_name[c_namesize rounded to 4 bytes]; */ 49 | /* char c_data[c_filesize rounded to 4 bytes]; */ 50 | } __attribute__((packed)); 51 | 52 | struct cpio_newc_node_info { 53 | struct inode* ci_self; 54 | struct cpio_newc_node_info* ci_parent; 55 | struct cpio_newc_node_info* ci_children; 56 | struct cpio_newc_node_info* ci_next_sibling; 57 | char* ci_name; 58 | char* ci_linktargetname; 59 | }; 60 | 61 | /* modes */ 62 | #define IALLOC 0100000 /* i-node is allocated */ 63 | #define ILARG 010000 /* large file */ 64 | #define IFMT 0170000 /* type of file */ 65 | 66 | static inline mode_t 67 | ancientfs_cpio_newc_mode(mode_t mode, uint32_t flags) 68 | { 69 | return mode & (uint16_t)~(IALLOC & ILARG); 70 | } 71 | 72 | #endif /* _ANCIENTFS_CPIO_NEWC_H_ */ 73 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_cpio_odc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_CPIO_ODC_H_ 8 | #define _ANCIENTFS_CPIO_ODC_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | #define ROOTINO 1 14 | 15 | struct filsys 16 | { 17 | uint32_t s_fsize; 18 | uint32_t s_files; 19 | uint32_t s_directories; 20 | uint32_t s_lastino; 21 | uint32_t s_dataoffset; 22 | uint32_t s_needsswap; 23 | struct inode* s_rootip; 24 | }; 25 | 26 | #define CPIO_ODC_BLOCK 512 27 | #define CPIO_ODC_MAGIC "070707" 28 | #define CPIO_ODC_MAGLEN 6 29 | #define CPIO_ODC_TRAILER "TRAILER!!!" 30 | #define CPIO_ODC_TRAILER_LEN (sizeof(CPIO_ODC_TRAILER)/sizeof(unsigned char)) 31 | 32 | struct cpio_odc_header { 33 | char c_magic[6]; 34 | char c_dev[6]; 35 | char c_ino[6]; 36 | char c_mode[6]; 37 | char c_uid[6]; 38 | char c_gid[6]; 39 | char c_nlink[6]; 40 | char c_rdev[6]; 41 | char c_mtime[11]; 42 | char c_namesize[6]; 43 | char c_filesize[11]; 44 | /* char c_name[c_namesize]; */ 45 | /* char c_data[c_filesize]; */ 46 | } __attribute__((packed)); 47 | 48 | struct cpio_odc_node_info { 49 | struct inode* ci_self; 50 | struct cpio_odc_node_info* ci_parent; 51 | struct cpio_odc_node_info* ci_children; 52 | struct cpio_odc_node_info* ci_next_sibling; 53 | char* ci_name; 54 | char* ci_linktargetname; 55 | }; 56 | 57 | /* modes */ 58 | #define IALLOC 0100000 /* i-node is allocated */ 59 | #define ILARG 010000 /* large file */ 60 | #define IFMT 0170000 /* type of file */ 61 | 62 | static inline mode_t 63 | ancientfs_cpio_odc_mode(mode_t mode, uint32_t flags) 64 | { 65 | return mode & (uint16_t)~(IALLOC & ILARG); 66 | } 67 | 68 | #endif /* _ANCIENTFS_CPIO_ODC_H_ */ 69 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_dtp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_DTP_H_ 8 | #define _ANCIENTFS_DTP_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | #define BSIZE 512 14 | 15 | #define ROOTINO 1 16 | #define DIRSIZ 14 17 | #define PATHSIZ 114 18 | 19 | struct filsys 20 | { 21 | uint32_t s_fsize; 22 | uint32_t s_files; 23 | uint32_t s_directories; 24 | uint32_t s_lastino; 25 | uint32_t s_dataoffset; 26 | struct inode* s_rootip; 27 | }; 28 | 29 | struct dinode_dtp { /* newer */ 30 | uint8_t di_path[PATHSIZ]; /* if di_path[0] == 0, the entry is empty */ 31 | uint16_t di_mode; /* type and permissions */ 32 | uint8_t di_uid; /* owner's id */ 33 | uint8_t di_gid; /* group's id */ 34 | uint8_t di_unused1; /* unused */ 35 | uint8_t di_size0; /* size */ 36 | uint16_t di_size1; /* size */ 37 | uint32_t di_mtime; /* file's modification time */ 38 | uint16_t di_addr; /* tape block of the start of the file's contents */ 39 | } __attribute__((packed)); 40 | 41 | #define INOPB 4 42 | 43 | struct tap_node_info { 44 | struct inode* ti_self; 45 | uint8_t ti_name[DIRSIZ]; 46 | struct tap_node_info* ti_parent; 47 | struct tap_node_info* ti_children; 48 | struct tap_node_info* ti_next_sibling; 49 | }; 50 | 51 | /* flags */ 52 | #define ILOCK 01 53 | #define IUPD 02 54 | #define IACC 04 55 | #define IMOUNT 010 56 | #define IWANT 020 57 | #define ITEXT 040 58 | 59 | /* modes */ 60 | #define IALLOC 0100000 /* i-node is allocated */ 61 | #define IFMT 060000 62 | #define IFDIR 040000 /* directory */ 63 | #define IMOD 020000 /* file has been modified (always on) */ 64 | #define ILARG 010000 /* large file */ 65 | #define ISUID 000040 /* set user ID on execution */ 66 | #define IEXEC 000020 /* executable */ 67 | #define IRUSR 000010 /* read, owner */ 68 | #define IWUSR 000004 /* write, owner */ 69 | #define IROTH 000002 /* read, non-owner */ 70 | #define IWOTH 000001 /* write, non-owner */ 71 | 72 | #include 73 | 74 | static inline mode_t 75 | ancientfs_dtp_mode(mode_t mode, uint32_t flags) 76 | { 77 | mode_t newmode = 0; 78 | 79 | newmode = (int)mode & ~(IALLOC | ILARG); 80 | if ((newmode & IFMT) == 0) /* ancient regular file */ 81 | newmode |= S_IFREG; 82 | return newmode; 83 | } 84 | 85 | #endif /* _ANCIENTFS_DTP_H_ */ 86 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_dump1024.c: -------------------------------------------------------------------------------- 1 | #define UCB_NKB 1 2 | #include "ancientfs_dump.c" 3 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_dumpvn1024.c: -------------------------------------------------------------------------------- 1 | #define UCB_NKB 1 2 | #include "ancientfs_dumpvn.c" 3 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_itp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_ITP_H_ 8 | #define _ANCIENTFS_ITP_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | #define BSIZE 512 14 | 15 | #define ROOTINO 1 16 | #define DIRSIZ 14 17 | #define PATHSIZ 48 18 | 19 | struct filsys 20 | { 21 | uint32_t s_fsize; 22 | uint32_t s_files; 23 | uint32_t s_directories; 24 | uint32_t s_lastino; 25 | struct inode* s_rootip; 26 | }; 27 | 28 | struct dinode_itp { /* newer */ 29 | uint8_t di_path[PATHSIZ]; /* if di_path[0] == 0, the entry is empty */ 30 | uint16_t di_mode; /* type and permissions */ 31 | uint8_t di_uid; /* owner's id */ 32 | uint8_t di_gid; /* group's id */ 33 | uint8_t di_unused1; /* unused */ 34 | uint8_t di_size0; /* size */ 35 | uint16_t di_size1; /* size */ 36 | uint32_t di_mtime; /* file's modification time */ 37 | uint16_t di_addr; /* tape block of the start of the file's contents */ 38 | uint16_t di_cksum; /* sum of the 32 words of the directory is 0 */ 39 | } __attribute__((packed)); 40 | 41 | #define INOPB 8 42 | 43 | struct tap_node_info { 44 | struct inode* ti_self; 45 | uint8_t ti_name[DIRSIZ]; 46 | struct tap_node_info* ti_parent; 47 | struct tap_node_info* ti_children; 48 | struct tap_node_info* ti_next_sibling; 49 | }; 50 | 51 | /* flags */ 52 | #define ILOCK 01 53 | #define IUPD 02 54 | #define IACC 04 55 | #define IMOUNT 010 56 | #define IWANT 020 57 | #define ITEXT 040 58 | 59 | /* modes */ 60 | #define IALLOC 0100000 /* file is used */ 61 | #define IFMT 060000 /* type of file */ 62 | #define IFDIR 040000 /* directory */ 63 | #define IFCHR 020000 /* character special */ 64 | #define IFBLK 060000 /* block special, 0 is regular */ 65 | #define ILARG 010000 /* large addressing algorithm */ 66 | #define ISUID 04000 /* set user id on execution */ 67 | #define ISGID 02000 /* set group id on execution */ 68 | #define ISVTX 01000 /* save swapped text even after use */ 69 | #define IREAD 0400 /* read, write, execute permissions */ 70 | #define IRWRITE 0200 71 | #define IEXEC 0100 72 | 73 | #include 74 | 75 | static inline mode_t 76 | ancientfs_itp_mode(mode_t mode, uint32_t flags) 77 | { 78 | mode_t newmode = 0; 79 | 80 | newmode = (int)mode & ~(IALLOC | ILARG); 81 | if ((newmode & IFMT) == 0) /* ancient regular file */ 82 | newmode |= S_IFREG; 83 | return newmode; 84 | } 85 | 86 | static inline int 87 | ancientfs_itp_cksum(uint8_t* de, fs_endian_t e, uint32_t flags) 88 | { 89 | uint16_t* p = (uint16_t*)de; 90 | uint16_t cksum = 0; 91 | int i = 0; 92 | for (i = 0; i < 32; i++, p++) 93 | cksum += fs16_to_host(e, *p); 94 | return cksum; 95 | } 96 | 97 | #endif /* _ANCIENTFS_ITP_H_ */ 98 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_oar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_OAR_H_ 8 | #define _ANCIENTFS_OAR_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | typedef int16_t a_short; /* ancient short */ 14 | typedef uint16_t a_ushort; /* ancient unsigned short */ 15 | typedef int16_t a_int; /* ancient int */ 16 | typedef uint16_t a_uint; /* ancient unsigned int */ 17 | typedef int32_t a_long; /* ancient long */ 18 | typedef uint32_t a_ulong; /* ancient unsigned long */ 19 | 20 | typedef a_uint a_ino_t; /* ancient inode type (ancient unsigned int) */ 21 | typedef a_long a_off_t; /* ancient offset type (ancient long) */ 22 | typedef a_long a_time_t; /* ancient time type (ancient long) */ 23 | typedef a_long a_daddr_t; /* ancient disk address type (ancient long) */ 24 | typedef a_int a_dev_t; /* ancient device type (ancient int) */ 25 | 26 | #define BSIZE 512 27 | #define BMASK 0777 /* BSIZE - 1 */ 28 | 29 | #define ROOTINO 1 30 | #define DIRSIZ 14 31 | 32 | struct filsys 33 | { 34 | uint32_t s_fsize; 35 | uint32_t s_files; 36 | uint32_t s_directories; 37 | uint32_t s_lastino; 38 | struct inode* s_rootip; 39 | }; 40 | 41 | #define ARMAG (uint16_t)0177545 42 | 43 | struct ar_hdr 44 | { 45 | char ar_name[DIRSIZ]; 46 | a_long ar_date; 47 | char ar_uid; 48 | char ar_gid; 49 | a_int ar_mode; 50 | a_long ar_size; 51 | } __attribute__((packed)); 52 | 53 | struct ar_node_info 54 | { 55 | struct inode* ar_self; 56 | uint8_t ar_name[DIRSIZ + 1]; 57 | struct ar_node_info* ar_parent; 58 | struct ar_node_info* ar_children; 59 | struct ar_node_info* ar_next_sibling; 60 | }; 61 | 62 | /* modes */ 63 | #define IALLOC 0100000 /* file is used */ 64 | #define IFMT 060000 65 | #define ILARG 010000 /* large addressing algorithm */ 66 | 67 | static inline a_int 68 | ancientfs_ar_mode(mode_t mode) 69 | { 70 | a_int newmode = (a_int)mode & ~(IALLOC | ILARG); 71 | if ((newmode & IFMT) == 0) /* ancient regular file */ 72 | newmode |= S_IFREG; 73 | return newmode; 74 | } 75 | 76 | #endif /* _ANCIENTFS_OAR_H_ */ 77 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_tar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_TAR_H_ 8 | #define _ANCIENTFS_TAR_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | #define TBLOCK 512 14 | #define NAMSIZ 100 15 | 16 | #define ROOTINO 1 17 | 18 | struct filsys 19 | { 20 | uint32_t s_fsize; 21 | uint32_t s_files; 22 | uint32_t s_directories; 23 | uint32_t s_lastino; 24 | uint32_t s_dataoffset; 25 | struct inode* s_rootip; 26 | }; 27 | 28 | #define TMAGIC "ustar" /* space terminated (pre POSIX) or null terminated */ 29 | #define TMAGLEN 6 30 | #define TVERSION "00" /* not null terminated */ 31 | #define TVERSLEN 2 32 | 33 | union hblock { 34 | char dummy[TBLOCK]; 35 | struct header { 36 | char name[NAMSIZ]; /* name of file */ 37 | char mode[8]; /* file mode */ 38 | char uid[8]; /* owner user ID */ 39 | char gid[8]; /* owner group ID */ 40 | char size[12]; /* length of file in bytes; no trailing null */ 41 | char mtime[12]; /* modfiy time of file; no trailing null */ 42 | char chksum[8]; /* checksum for header */ 43 | char typeflag; /* called linkflag in pre-ustar headers */ 44 | char linkname[NAMSIZ]; /* name of linked file */ 45 | /* ustar below */ 46 | char magic[6]; /* USTAR indicator */ 47 | char version[2]; /* USTAR version; no trailing null */ 48 | char uname[32]; /* owner user name */ 49 | char gname[32]; /* owner group name */ 50 | char devmajor[8]; /* device major number */ 51 | char devminor[8]; /* device minor number */ 52 | char prefix[155]; /* prefix for file name */ 53 | } dbuf; 54 | }; 55 | 56 | /* values of typeflag / linkflag */ 57 | #define TARTYPE_REG '0' /* USTAR and old tar */ 58 | #define TARTYPE_LNK '1' /* USTAR and old tar */ 59 | #define TARTYPE_SYM '2' /* USTAR and old tar */ 60 | #define TARTYPE_CHR '3' /* USTAR */ 61 | #define TARTYPE_BLK '4' /* USTAR */ 62 | #define TARTYPE_DIR '5' /* USTAR */ 63 | #define TARTYPE_FIFO '6' /* USTAR */ 64 | 65 | struct tar_node_info { 66 | struct inode* ti_self; 67 | struct tar_node_info* ti_parent; 68 | struct tar_node_info* ti_children; 69 | struct tar_node_info* ti_next_sibling; 70 | char* ti_name; 71 | char* ti_linktargetname; 72 | }; 73 | 74 | /* modes */ 75 | #define IALLOC 0100000 /* i-node is allocated */ 76 | #define ILARG 010000 /* large file */ 77 | #define IFMT 0170000 /* type of file */ 78 | 79 | static inline mode_t 80 | ancientfs_tar_mode(mode_t mode, uint32_t flags) 81 | { 82 | return mode & (uint16_t)~(IALLOC & ILARG); 83 | } 84 | 85 | #endif /* _ANCIENTFS_TAR_H_ */ 86 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_tp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_TP_H_ 8 | #define _ANCIENTFS_TP_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | #define BSIZE 512 14 | 15 | #define ROOTINO 1 16 | #define DIRSIZ 14 17 | #define PATHSIZ 32 18 | 19 | struct filsys 20 | { 21 | uint32_t s_fsize; 22 | uint32_t s_files; 23 | uint32_t s_directories; 24 | uint32_t s_lastino; 25 | struct inode* s_rootip; 26 | }; 27 | 28 | struct dinode_tp { /* newer */ 29 | uint8_t di_path[PATHSIZ]; /* if di_path[0] == 0, the entry is empty */ 30 | uint16_t di_mode; /* type and permissions */ 31 | uint8_t di_uid; /* owner's id */ 32 | uint8_t di_gid; /* group's id */ 33 | uint8_t di_unused1; /* unused */ 34 | uint8_t di_size0; /* size */ 35 | uint16_t di_size1; /* size */ 36 | uint32_t di_mtime; /* file's modification time */ 37 | uint16_t di_addr; /* tape block of the start of the file's contents */ 38 | uint8_t di_unused2[16];/* unused */ 39 | uint16_t di_cksum; /* sum of the 32 words of the directory is 0 */ 40 | } __attribute__((packed)); 41 | 42 | #define INOPB 8 43 | 44 | struct tap_node_info { 45 | struct inode* ti_self; 46 | uint8_t ti_name[DIRSIZ]; 47 | struct tap_node_info* ti_parent; 48 | struct tap_node_info* ti_children; 49 | struct tap_node_info* ti_next_sibling; 50 | }; 51 | 52 | /* flags */ 53 | #define ILOCK 01 54 | #define IUPD 02 55 | #define IACC 04 56 | #define IMOUNT 010 57 | #define IWANT 020 58 | #define ITEXT 040 59 | 60 | /* modes */ 61 | #define IALLOC 0100000 /* file is used */ 62 | #define IFMT 060000 /* type of file */ 63 | #define IFDIR 040000 /* directory */ 64 | #define IFCHR 020000 /* character special */ 65 | #define IFBLK 060000 /* block special, 0 is regular */ 66 | #define ILARG 010000 /* large addressing algorithm */ 67 | #define ISUID 04000 /* set user id on execution */ 68 | #define ISGID 02000 /* set group id on execution */ 69 | #define ISVTX 01000 /* save swapped text even after use */ 70 | #define IREAD 0400 /* read, write, execute permissions */ 71 | #define IRWRITE 0200 72 | #define IEXEC 0100 73 | 74 | #include 75 | 76 | static inline mode_t 77 | ancientfs_tp_mode(mode_t mode, uint32_t flags) 78 | { 79 | mode_t newmode = 0; 80 | 81 | newmode = (int)mode & ~(IALLOC | ILARG); 82 | if ((newmode & IFMT) == 0) /* ancient regular file */ 83 | newmode |= S_IFREG; 84 | return newmode; 85 | } 86 | 87 | static inline int 88 | ancientfs_tp_cksum(uint8_t* de, fs_endian_t e, uint32_t flags) 89 | { 90 | uint16_t* p = (uint16_t*)de; 91 | uint16_t cksum = 0; 92 | int i = 0; 93 | for (i = 0; i < 32; i++, p++) 94 | cksum += fs16_to_host(e, *p); 95 | return cksum; 96 | } 97 | 98 | #endif /* _ANCIENTFS_TP_H_ */ 99 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_v10.c: -------------------------------------------------------------------------------- 1 | #define V10_4K 1 2 | #include "ancientfs_v7.c" 3 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_v4,5,6.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_V456_H_ 8 | #define _ANCIENTFS_V456_H_ 9 | 10 | /* 11 | * V4 += DIRSIZ 14, size0/size1, groups, 1970 epoch with full seconds 12 | * V5 += ISVTX 13 | */ 14 | 15 | #include "unixfs_internal.h" 16 | #include "ancientfs.h" 17 | 18 | typedef int16_t a_ino_t; /* ancient inode type */ 19 | typedef int16_t a_int; /* ancient int */ 20 | 21 | #define BSIZE 512 22 | 23 | #define ROOTINO 1 /* i number of all roots */ 24 | #define SUPERB 1 /* block number of the super block */ 25 | #define DIRSIZ 14 /* max characters per directory */ 26 | 27 | /* 28 | * Definition of the unix super block. 29 | */ 30 | struct filsys 31 | { 32 | a_int s_isize; /* size in blocks of the I list */ 33 | a_int s_fsize; /* size in blocks of entire volume */ 34 | a_int s_nfree; /* number of in core free blocks (0 - 100) */ 35 | a_int s_free[100]; /* in core free blocks */ 36 | a_int s_ninode; /* number of in core I nodes (0 - 100) */ 37 | a_ino_t s_inode[100]; /* in core free I nodes */ 38 | char s_flock; /* lock during free list manipulation */ 39 | char s_ilock; /* lock during I list manipulation */ 40 | char s_fmod; /* super block modified flag */ 41 | char s_ronly; /* mounted read-only flag */ 42 | a_int s_time[2]; /* current date of last update */ 43 | a_int pad[50]; 44 | } __attribute__((packed)); 45 | 46 | /* 47 | * Inode struct as it appears on the disk. 48 | */ 49 | struct dinode 50 | { 51 | a_int di_mode; /* type and permissions */ 52 | char di_nlink; /* directory entries */ 53 | char di_uid; /* owner */ 54 | char di_gid; /* group of owner */ 55 | char di_size0; /* most significant of size */ 56 | a_int di_size1; /* least significant of size */ 57 | a_int di_addr[8]; /* device addresses constituting file */ 58 | a_int di_atime[2]; /* access time */ 59 | a_int di_mtime[2]; /* modification time */ 60 | } __attribute__((packed)); 61 | 62 | /* flags */ 63 | #define ILOCK 01 /* inode is locked */ 64 | #define IUPD 02 /* inode has been modified */ 65 | #define IACC 04 /* inode access time to be updated */ 66 | #define IMOUNT 010 /* inode is mounted on */ 67 | #define IWANT 020 /* some process waiting on lock */ 68 | #define ITEXT 040 /* inode is pure text prototype */ 69 | 70 | /* modes */ 71 | #define IALLOC 0100000 /* file is used */ 72 | #define IFMT 060000 /* type of file */ 73 | #define IFDIR 040000 /* directory */ 74 | #define IFCHR 020000 /* character special */ 75 | #define IFBLK 060000 /* block special, 0 is regular */ 76 | #define ILARG 010000 /* large addressing algorithm */ 77 | #define ISUID 04000 /* set user id on execution */ 78 | #define ISGID 02000 /* set group id on execution */ 79 | #define ISVTX 01000 /* save swapped text even after use */ 80 | #define IREAD 0400 /* read, write, execute permissions */ 81 | #define IRWRITE 0200 82 | #define IEXEC 0100 83 | 84 | static inline a_int 85 | ancientfs_v456_mode(mode_t mode) 86 | { 87 | a_int newmode = (a_int)mode & ~(IALLOC | ILARG); 88 | if ((newmode & IFMT) == 0) /* ancient regular file */ 89 | newmode |= S_IFREG; 90 | return newmode; 91 | } 92 | 93 | struct dent { 94 | a_ino_t u_ino; /* inode table pointer */ 95 | char u_name[DIRSIZ]; /* component name */ 96 | } __attribute__((packed)); 97 | 98 | #endif /* _ANCIENTFS_V456_H_ */ 99 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ancientfs/ancientfs_voar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ancient UNIX File Systems for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _ANCIENTFS_VOAR_H_ 8 | #define _ANCIENTFS_VOAR_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "ancientfs.h" 12 | 13 | typedef int16_t a_short; /* ancient short */ 14 | typedef uint16_t a_ushort; /* ancient unsigned short */ 15 | typedef int16_t a_int; /* ancient int */ 16 | typedef uint16_t a_uint; /* ancient unsigned int */ 17 | typedef int32_t a_long; /* ancient long */ 18 | typedef uint32_t a_ulong; /* ancient unsigned long */ 19 | 20 | typedef a_uint a_ino_t; /* ancient inode type (ancient unsigned int) */ 21 | typedef a_long a_off_t; /* ancient offset type (ancient long) */ 22 | typedef a_long a_time_t; /* ancient time type (ancient long) */ 23 | typedef a_long a_daddr_t; /* ancient disk address type (ancient long) */ 24 | typedef a_int a_dev_t; /* ancient device type (ancient int) */ 25 | 26 | #define BSIZE 512 27 | #define BMASK 0777 /* BSIZE - 1 */ 28 | 29 | #define ROOTINO 1 30 | #define DIRSIZ 8 31 | 32 | struct filsys 33 | { 34 | uint32_t s_fsize; 35 | uint32_t s_files; 36 | uint32_t s_directories; 37 | uint32_t s_lastino; 38 | struct inode* s_rootip; 39 | }; 40 | 41 | #define ARMAG (uint16_t)0177555 42 | 43 | struct ar_hdr 44 | { 45 | char ar_name[DIRSIZ]; 46 | a_long ar_date; 47 | char ar_uid; 48 | char ar_mode; 49 | a_int ar_size; 50 | } __attribute__((packed)); 51 | 52 | struct ar_node_info 53 | { 54 | struct inode* ar_self; 55 | uint8_t ar_name[DIRSIZ + 1]; 56 | struct ar_node_info* ar_parent; 57 | struct ar_node_info* ar_children; 58 | struct ar_node_info* ar_next_sibling; 59 | }; 60 | 61 | /* modes */ 62 | #define IALLOC 0100000 /* i-node is allocated */ 63 | #define IFMT 060000 64 | #define IFDIR 040000 /* directory */ 65 | #define IMOD 020000 /* file has been modified (always on) */ 66 | #define ILARG 010000 /* large file */ 67 | 68 | /* v1 mode bits */ 69 | #define ISUID 000040 /* set user ID on execution */ 70 | #define IEXEC 000020 /* executable */ 71 | #define IRUSR 000010 /* read, owner */ 72 | #define IWUSR 000004 /* write, owner */ 73 | #define IROTH 000002 /* read, non-owner */ 74 | #define IWOTH 000001 /* write, non-owner */ 75 | 76 | #include 77 | 78 | static inline a_int 79 | ancientfs_ar_mode(mode_t mode, uint32_t flags) 80 | { 81 | mode_t newmode = 0; 82 | 83 | if ((flags & ANCIENTFS_UNIX_V1) || 84 | (flags & ANCIENTFS_UNIX_V2) || 85 | (flags & ANCIENTFS_UNIX_V3)) 86 | goto old; 87 | 88 | newmode = (uint8_t)mode & ~(IALLOC | ILARG); 89 | if ((newmode & IFMT) == 0) /* ancient regular file */ 90 | newmode |= S_IFREG; 91 | return newmode; 92 | 93 | old: 94 | 95 | /* older mode bits */ 96 | 97 | if ((mode & IFMT) == IFDIR) 98 | newmode |= S_IFDIR; 99 | else 100 | newmode |= S_IFREG; 101 | 102 | if (mode & ISUID) 103 | newmode |= S_ISUID; 104 | 105 | if (mode & IEXEC) 106 | newmode |= S_IXUSR; 107 | 108 | if (mode & IRUSR) 109 | newmode |= S_IRUSR; 110 | 111 | if (mode & IWUSR) 112 | newmode |= S_IWUSR; 113 | 114 | if (mode & IROTH) { 115 | newmode |= S_IROTH; 116 | if (mode & IEXEC) 117 | newmode |= S_IXOTH; 118 | } 119 | 120 | if (mode & IWOTH) 121 | newmode |= S_IWOTH; 122 | 123 | return newmode; 124 | } 125 | 126 | /* 127 | * v1 00:00 Jan 1, 1971 /60 128 | * v2 00:00 Jan 1, 1971 /60 129 | * v3 00:00 Jan 1, 1972 /60 130 | * 131 | * modern 00:00 Jan 1, 1970 full seconds 132 | */ 133 | static inline uint32_t 134 | ancientfs_ar_time(uint32_t t, uint32_t flags) 135 | { 136 | if (!(flags & (ANCIENTFS_UNIX_V1 | ANCIENTFS_UNIX_V2 | ANCIENTFS_UNIX_V3))) 137 | return t; 138 | 139 | uint32_t cvt = t; 140 | 141 | cvt = cvt / 60; /* times were measured in sixtieths of a second */ 142 | 143 | uint32_t epoch_years = (flags & ANCIENTFS_UNIX_V1) ? 1 : 144 | (flags & ANCIENTFS_UNIX_V2) ? 1 : 145 | (flags & ANCIENTFS_UNIX_V3) ? 2 : 0; 146 | 147 | cvt += (epoch_years * 365 * 24 * 3600); /* epoch fixup */ 148 | 149 | return cvt; 150 | } 151 | 152 | #endif /* _ANCIENTFS_VOAR_H_ */ 153 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/fs/ufs/swab.h: -------------------------------------------------------------------------------- 1 | /* 2 | * linux/fs/ufs/swab.h 3 | * 4 | * Copyright (C) 1997, 1998 Francois-Rene Rideau 5 | * Copyright (C) 1998 Jakub Jelinek 6 | * Copyright (C) 2001 Christoph Hellwig 7 | */ 8 | 9 | #ifndef _UFS_SWAB_H 10 | #define _UFS_SWAB_H 11 | 12 | /* 13 | * Notes: 14 | * HERE WE ASSUME EITHER BIG OR LITTLE ENDIAN UFSes 15 | * in case there are ufs implementations that have strange bytesexes, 16 | * you'll need to modify code here as well as in ufs_super.c and ufs_fs.h 17 | * to support them. 18 | */ 19 | 20 | enum { 21 | BYTESEX_LE, 22 | BYTESEX_BE 23 | }; 24 | 25 | static inline u64 26 | fs64_to_cpu(struct super_block *sbp, __fs64 n) 27 | { 28 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 29 | return le64_to_cpu((__force __le64)n); 30 | else 31 | return be64_to_cpu((__force __be64)n); 32 | } 33 | 34 | static inline __fs64 35 | cpu_to_fs64(struct super_block *sbp, u64 n) 36 | { 37 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 38 | return (__force __fs64)cpu_to_le64(n); 39 | else 40 | return (__force __fs64)cpu_to_be64(n); 41 | } 42 | 43 | static inline u32 44 | fs32_to_cpu(struct super_block *sbp, __fs32 n) 45 | { 46 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 47 | return le32_to_cpu((__force __le32)n); 48 | else 49 | return be32_to_cpu((__force __be32)n); 50 | } 51 | 52 | static inline __fs32 53 | cpu_to_fs32(struct super_block *sbp, u32 n) 54 | { 55 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 56 | return (__force __fs32)cpu_to_le32(n); 57 | else 58 | return (__force __fs32)cpu_to_be32(n); 59 | } 60 | 61 | static inline void 62 | fs32_add(struct super_block *sbp, __fs32 *n, int d) 63 | { 64 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 65 | le32_add_cpu((__le32 *)n, d); 66 | else 67 | be32_add_cpu((__be32 *)n, d); 68 | } 69 | 70 | static inline void 71 | fs32_sub(struct super_block *sbp, __fs32 *n, int d) 72 | { 73 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 74 | le32_add_cpu((__le32 *)n, -d); 75 | else 76 | be32_add_cpu((__be32 *)n, -d); 77 | } 78 | 79 | static inline u16 80 | fs16_to_cpu(struct super_block *sbp, __fs16 n) 81 | { 82 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 83 | return le16_to_cpu((__force __le16)n); 84 | else 85 | return be16_to_cpu((__force __be16)n); 86 | } 87 | 88 | static inline __fs16 89 | cpu_to_fs16(struct super_block *sbp, u16 n) 90 | { 91 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 92 | return (__force __fs16)cpu_to_le16(n); 93 | else 94 | return (__force __fs16)cpu_to_be16(n); 95 | } 96 | 97 | static inline void 98 | fs16_add(struct super_block *sbp, __fs16 *n, int d) 99 | { 100 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 101 | le16_add_cpu((__le16 *)n, d); 102 | else 103 | be16_add_cpu((__be16 *)n, d); 104 | } 105 | 106 | static inline void 107 | fs16_sub(struct super_block *sbp, __fs16 *n, int d) 108 | { 109 | if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE) 110 | le16_add_cpu((__le16 *)n, -d); 111 | else 112 | be16_add_cpu((__be16 *)n, -d); 113 | } 114 | 115 | #endif /* _UFS_SWAB_H */ 116 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/asm/div64.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/asm/div64.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/bitops.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/bitops.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/blockgroup_lock.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/blockgroup_lock.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/buffer_head.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/buffer_head.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/ctype.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/div64.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/div64.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/ext2_fs_sb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * linux/include/linux/ext2_fs_sb.h 3 | * 4 | * Copyright (C) 1992, 1993, 1994, 1995 5 | * Remy Card (card@masi.ibp.fr) 6 | * Laboratoire MASI - Institut Blaise Pascal 7 | * Universite Pierre et Marie Curie (Paris VI) 8 | * 9 | * from 10 | * 11 | * linux/include/linux/minix_fs_sb.h 12 | * 13 | * Copyright (C) 1991, 1992 Linus Torvalds 14 | */ 15 | 16 | #ifndef _LINUX_EXT2_FS_SB 17 | #define _LINUX_EXT2_FS_SB 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | /* XXX Here for now... not interested in restructing headers JUST now */ 24 | 25 | /* data type for block offset of block group */ 26 | typedef int ext2_grpblk_t; 27 | 28 | /* data type for filesystem-wide blocks number */ 29 | typedef unsigned long ext2_fsblk_t; 30 | 31 | #define E2FSBLK "%lu" 32 | 33 | struct ext2_reserve_window { 34 | ext2_fsblk_t _rsv_start; /* First byte reserved */ 35 | ext2_fsblk_t _rsv_end; /* Last byte reserved or 0 */ 36 | }; 37 | 38 | struct ext2_reserve_window_node { 39 | struct rb_node rsv_node; 40 | __u32 rsv_goal_size; 41 | __u32 rsv_alloc_hit; 42 | struct ext2_reserve_window rsv_window; 43 | }; 44 | 45 | struct ext2_block_alloc_info { 46 | /* information about reservation window */ 47 | struct ext2_reserve_window_node rsv_window_node; 48 | /* 49 | * was i_next_alloc_block in ext2_inode_info 50 | * is the logical (file-relative) number of the 51 | * most-recently-allocated block in this file. 52 | * We use this for detecting linearly ascending allocation requests. 53 | */ 54 | __u32 last_alloc_logical_block; 55 | /* 56 | * Was i_next_alloc_goal in ext2_inode_info 57 | * is the *physical* companion to i_next_alloc_block. 58 | * it the the physical block number of the block which was most-recentl 59 | * allocated to this file. This give us the goal (target) for the next 60 | * allocation when we detect linearly ascending requests. 61 | */ 62 | ext2_fsblk_t last_alloc_physical_block; 63 | }; 64 | 65 | #define rsv_start rsv_window._rsv_start 66 | #define rsv_end rsv_window._rsv_end 67 | 68 | /* 69 | * second extended-fs super-block data in memory 70 | */ 71 | struct ext2_sb_info { 72 | unsigned long s_frag_size; /* Size of a fragment in bytes */ 73 | unsigned long s_frags_per_block;/* Number of fragments per block */ 74 | unsigned long s_inodes_per_block;/* Number of inodes per block */ 75 | unsigned long s_frags_per_group;/* Number of fragments in a group */ 76 | unsigned long s_blocks_per_group;/* Number of blocks in a group */ 77 | unsigned long s_inodes_per_group;/* Number of inodes in a group */ 78 | unsigned long s_itb_per_group; /* Number of inode table blocks per group */ 79 | unsigned long s_gdb_count; /* Number of group descriptor blocks */ 80 | unsigned long s_desc_per_block; /* Number of group descriptors per block */ 81 | unsigned long s_groups_count; /* Number of groups in the fs */ 82 | unsigned long s_overhead_last; /* Last calculated overhead */ 83 | unsigned long s_blocks_last; /* Last seen block count */ 84 | struct buffer_head * s_sbh; /* Buffer containing the super block */ 85 | struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */ 86 | struct buffer_head ** s_group_desc; 87 | unsigned long s_mount_opt; 88 | unsigned long s_sb_block; 89 | uid_t s_resuid; 90 | gid_t s_resgid; 91 | unsigned short s_mount_state; 92 | unsigned short s_pad; 93 | int s_addr_per_block_bits; 94 | int s_desc_per_block_bits; 95 | int s_inode_size; 96 | int s_first_ino; 97 | spinlock_t s_next_gen_lock; 98 | u32 s_next_generation; 99 | unsigned long s_dir_count; 100 | u8 *s_debts; 101 | struct percpu_counter s_freeblocks_counter; 102 | struct percpu_counter s_freeinodes_counter; 103 | struct percpu_counter s_dirs_counter; 104 | struct blockgroup_lock s_blockgroup_lock; 105 | /* root of the per fs reservation window tree */ 106 | spinlock_t s_rsv_window_lock; 107 | struct rb_root s_rsv_window_root; 108 | struct ext2_reserve_window_node s_rsv_window_head; 109 | }; 110 | 111 | #endif /* _LINUX_EXT2_FS_SB */ 112 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/fs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/fs.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/highmem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/highmem.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/kernel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/kernel.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/magic.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_MAGIC_H__ 2 | #define __LINUX_MAGIC_H__ 3 | 4 | #define ADFS_SUPER_MAGIC 0xadf5 5 | #define AFFS_SUPER_MAGIC 0xadff 6 | #define AFS_SUPER_MAGIC 0x5346414F 7 | #define AUTOFS_SUPER_MAGIC 0x0187 8 | #define CODA_SUPER_MAGIC 0x73757245 9 | #define EFS_SUPER_MAGIC 0x414A53 10 | #define EXT2_SUPER_MAGIC 0xEF53 11 | #define EXT3_SUPER_MAGIC 0xEF53 12 | #define EXT4_SUPER_MAGIC 0xEF53 13 | #define HPFS_SUPER_MAGIC 0xf995e849 14 | #define ISOFS_SUPER_MAGIC 0x9660 15 | #define JFFS2_SUPER_MAGIC 0x72b6 16 | #define ANON_INODE_FS_MAGIC 0x09041934 17 | 18 | #define MINIX_SUPER_MAGIC 0x137F /* original minix fs */ 19 | #define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */ 20 | #define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */ 21 | #define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */ 22 | #define MINIX3_SUPER_MAGIC 0x4d5a /* minix V3 fs */ 23 | 24 | #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */ 25 | #define NCP_SUPER_MAGIC 0x564c /* Guess, what 0x564c is :-) */ 26 | #define NFS_SUPER_MAGIC 0x6969 27 | #define OPENPROM_SUPER_MAGIC 0x9fa1 28 | #define PROC_SUPER_MAGIC 0x9fa0 29 | #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */ 30 | 31 | #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */ 32 | /* used by file system utilities that 33 | look at the superblock, etc. */ 34 | #define REISERFS_SUPER_MAGIC_STRING "ReIsErFs" 35 | #define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" 36 | #define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs" 37 | 38 | #define SMB_SUPER_MAGIC 0x517B 39 | #define USBDEVICE_SUPER_MAGIC 0x9fa2 40 | #define CGROUP_SUPER_MAGIC 0x27e0eb 41 | 42 | #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA 43 | #define INOTIFYFS_SUPER_MAGIC 0x2BAD1DEA 44 | 45 | #endif /* __LINUX_MAGIC_H__ */ 46 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/minix_fs.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_MINIX_FS_H 2 | #define _LINUX_MINIX_FS_H 3 | 4 | #include 5 | 6 | /* 7 | * The minix filesystem constants/structures 8 | */ 9 | 10 | /* 11 | * Thanks to Kees J Bot for sending me the definitions of the new 12 | * minix filesystem (aka V2) with bigger inodes and 32-bit block 13 | * pointers. 14 | */ 15 | 16 | #define MINIX_ROOT_INO 1 17 | 18 | /* Not the same as the bogus LINK_MAX in . Oh well. */ 19 | #define MINIX_LINK_MAX 250 20 | #define MINIX2_LINK_MAX 65530 21 | 22 | #define MINIX_I_MAP_SLOTS 8 23 | #define MINIX_Z_MAP_SLOTS 64 24 | #define MINIX_VALID_FS 0x0001 /* Clean fs. */ 25 | #define MINIX_ERROR_FS 0x0002 /* fs has errors. */ 26 | 27 | #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode))) 28 | 29 | /* 30 | * This is the original minix inode layout on disk. 31 | * Note the 8-bit gid and atime and ctime. 32 | */ 33 | struct minix_inode { 34 | __u16 di_mode; 35 | __u16 di_uid; 36 | __u32 di_size; 37 | __u32 di_time; 38 | __u8 di_gid; 39 | __u8 di_nlinks; 40 | __u16 di_zone[9]; 41 | }; 42 | 43 | /* 44 | * The new minix inode has all the time entries, as well as 45 | * long block numbers and a third indirect block (7+1+1+1 46 | * instead of 7+1+1). Also, some previously 8-bit values are 47 | * now 16-bit. The inode is now 64 bytes instead of 32. 48 | */ 49 | struct minix2_inode { 50 | __u16 di_mode; 51 | __u16 di_nlinks; 52 | __u16 di_uid; 53 | __u16 di_gid; 54 | __u32 di_size; 55 | __u32 di_atime; 56 | __u32 di_mtime; 57 | __u32 di_ctime; 58 | __u32 di_zone[10]; 59 | }; 60 | 61 | /* 62 | * minix super-block data on disk 63 | */ 64 | struct minix_super_block { 65 | __u16 s_ninodes; 66 | __u16 s_nzones; 67 | __u16 s_imap_blocks; 68 | __u16 s_zmap_blocks; 69 | __u16 s_firstdatazone; 70 | __u16 s_log_zone_size; 71 | __u32 s_max_size; 72 | __u16 s_magic; 73 | __u16 s_state; 74 | __u32 s_zones; 75 | }; 76 | 77 | /* 78 | * V3 minix super-block data on disk 79 | */ 80 | struct minix3_super_block { 81 | __u32 s_ninodes; 82 | __u16 s_pad0; 83 | __u16 s_imap_blocks; 84 | __u16 s_zmap_blocks; 85 | __u16 s_firstdatazone; 86 | __u16 s_log_zone_size; 87 | __u16 s_pad1; 88 | __u32 s_max_size; 89 | __u32 s_zones; 90 | __u16 s_magic; 91 | __u16 s_pad2; 92 | __u16 s_blocksize; 93 | __u8 s_disk_version; 94 | }; 95 | 96 | struct minix_dir_entry { 97 | __u16 inode; 98 | char name[0]; 99 | }; 100 | 101 | struct minix3_dir_entry { 102 | __u32 inode; 103 | char name[0]; 104 | }; 105 | #endif 106 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/module.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/module.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * linux/include/linux/parser.h 3 | * 4 | * Header for lib/parser.c 5 | * Intended use of these functions is parsing filesystem argument lists, 6 | * but could potentially be used anywhere else that simple option=arg 7 | * parsing is required. 8 | */ 9 | 10 | 11 | /* associates an integer enumerator with a pattern string. */ 12 | struct match_token { 13 | int token; 14 | const char *pattern; 15 | }; 16 | 17 | typedef struct match_token match_table_t[]; 18 | 19 | /* Maximum number of arguments that match_token will find in a pattern */ 20 | enum {MAX_OPT_ARGS = 3}; 21 | 22 | /* Describe the location within a string of a substring */ 23 | typedef struct { 24 | char *from; 25 | char *to; 26 | } substring_t; 27 | 28 | int match_token(char *, match_table_t table, substring_t args[]); 29 | int match_int(substring_t *, int *result); 30 | int match_octal(substring_t *, int *result); 31 | int match_hex(substring_t *, int *result); 32 | size_t match_strlcpy(char *, const substring_t *, size_t); 33 | char *match_strdup(const substring_t *); 34 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/percpu_counter.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/percpu_counter.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/sched.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/sched.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/slab.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/slab.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/smp_lock.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/smp_lock.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/stat.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/stat.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/stddef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/stddef.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/string.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/string.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/swap.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/swap.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/kernel/include/linux/types.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-c/unixfs/common/linux/kernel/include/linux/types.h -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/linux/linux.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "unixfs_internal.h" 7 | #include "linux.h" 8 | 9 | int 10 | sb_bread_intobh(struct super_block* sb, off_t block, struct buffer_head* bh) 11 | { 12 | if (pread(sb->s_bdev, bh->b_data, sb->s_blocksize, 13 | block * (off_t)sb->s_blocksize) != sb->s_blocksize) 14 | return EIO; 15 | 16 | return 0; 17 | } 18 | 19 | void 20 | brelse(struct buffer_head* bh) 21 | { 22 | if (bh && bh->b_flags.dynamic) 23 | free((void*)bh); 24 | } 25 | 26 | struct buffer_head* 27 | sb_getblk(struct super_block* sb, sector_t block) 28 | { 29 | struct buffer_head* bh = calloc(1, sizeof(struct buffer_head)); 30 | if (!bh) { 31 | fprintf(stderr, "*** fatal error: cannot allocate buffer\n"); 32 | abort(); 33 | } 34 | bh->b_flags.dynamic = 1; 35 | bh->b_size = PAGE_SIZE; 36 | bh->b_blocknr = block; 37 | return bh; 38 | } 39 | 40 | struct buffer_head* 41 | sb_bread(struct super_block* sb, off_t block) 42 | { 43 | struct buffer_head* bh = sb_getblk(sb, block); 44 | if (bh && sb_bread_intobh(sb, block, bh) != 0) { 45 | brelse(bh); 46 | return NULL; 47 | } 48 | return bh; 49 | } 50 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/unixfs/unixfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UnixFS 3 | * 4 | * A general-purpose file system layer for writing/reimplementing/porting 5 | * Unix file systems through MacFUSE. 6 | 7 | * Copyright (c) 2008 Amit Singh. All Rights Reserved. 8 | * http://osxbook.com 9 | */ 10 | 11 | #ifndef _UNIXFS_H_ 12 | #define _UNIXFS_H_ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #define UNIXFS_MAXPATHLEN 1024 20 | #define UNIXFS_MAXNAMLEN 255 21 | #define UNIXFS_MNAMELEN 90 22 | #define UNIXFS_ARGLEN 1024 23 | 24 | typedef enum { 25 | UNIXFS_FS_PDP, 26 | UNIXFS_FS_LITTLE, 27 | UNIXFS_FS_BIG, 28 | UNIXFS_FS_INVALID, 29 | } fs_endian_t; 30 | 31 | struct unixfs_ops; 32 | 33 | /* Our encapsulation of an Ancient Unix file system instance. */ 34 | 35 | struct unixfs { 36 | struct unixfs_ops *ops; /* file system operations */ 37 | void* filsys; /* in-core super block */ 38 | uint32_t flags; /* directives/miscellaneous flags */ 39 | fs_endian_t fsendian; 40 | char* fsname; 41 | char* volname; 42 | }; 43 | 44 | /* flags */ 45 | 46 | #define UNIXFS_FORCE 0x00000001 /* mount even if things look fishy */ 47 | 48 | /* Our encapsulation of an Ancient Unix directory entry. */ 49 | 50 | struct unixfs_direntry { 51 | ino_t ino __attribute__((aligned(8))); 52 | char name[UNIXFS_MAXNAMLEN + 1]; 53 | }; 54 | 55 | #define UNIXFS_DIRBUFSIZ 8192 56 | 57 | struct unixfs_dirbuf { 58 | struct flags { 59 | uint32_t initialized; 60 | } flags; 61 | char data[UNIXFS_DIRBUFSIZ]; 62 | }; 63 | 64 | /* Interface to Ancient Unix file system internals. */ 65 | 66 | struct inode; 67 | struct stat; 68 | 69 | struct unixfs_ops { 70 | void* (*init)(const char* dmg, uint32_t flags, fs_endian_t fse, 71 | char** fsname, char** volname); 72 | void (*fini)(void*); 73 | off_t (*alloc)(void); 74 | off_t (*bmap)(struct inode* ip, off_t lblkno, int* error); 75 | int (*bread)(off_t blkno, char* blkbuf); 76 | struct inode* (*iget)(ino_t ino); 77 | void (*iput)(struct inode* ip); 78 | int (*igetattr)(ino_t ino, struct stat* stbuf); 79 | void (*istat)(struct inode* ip, struct stat* stbuf); 80 | int (*namei)(ino_t parentino, const char* name, 81 | struct stat* stbuf); 82 | int (*nextdirentry)(struct inode* ip, 83 | struct unixfs_dirbuf* dirbuf, 84 | off_t* offset, 85 | struct unixfs_direntry* dent); 86 | ssize_t (*pbread)(struct inode*ip, char* buf, size_t nbyte, 87 | off_t offset, int* error); 88 | int (*readlink)(ino_t, char path[UNIXFS_MAXPATHLEN]); 89 | int (*sanitycheck)(void* filsys, off_t disksize); 90 | int (*statvfs)(struct statvfs* svb); 91 | }; 92 | 93 | #define min(x, y) ((x) < (y) ? (x) : (y)) 94 | #define max(x, y) ((x) > (y) ? (x) : (y)) 95 | 96 | extern void unixfs_usage(void); 97 | extern struct unixfs* unixfs_preflight(char*, char**, struct unixfs**); 98 | extern void unixfs_postflight(char*, char*, char*); 99 | 100 | #endif /* _UNIXFS_H_ */ 101 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/common/unixfs/unixfs_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UnixFS 3 | * 4 | * A general-purpose file system layer for writing/reimplementing/porting 5 | * Unix file systems through MacFUSE. 6 | 7 | * Copyright (c) 2008 Amit Singh. All Rights Reserved. 8 | * http://osxbook.com 9 | */ 10 | 11 | #ifndef _UNIXFS_COMMON_H_ 12 | #define _UNIXFS_COMMON_H_ 13 | 14 | /* Implementation of Ancient Unix file system internals. */ 15 | 16 | static void* unixfs_internal_init(const char* dmg, uint32_t flags, 17 | fs_endian_t fse, char** fsname, 18 | char** volname); 19 | static void unixfs_internal_fini(void*); 20 | static off_t unixfs_internal_alloc(void); 21 | static off_t unixfs_internal_bmap(struct inode* ip, off_t lblkno, 22 | int* error); 23 | static int unixfs_internal_bread(off_t blkno, char *blkbuf); 24 | static struct inode* unixfs_internal_iget(ino_t ino); 25 | static void unixfs_internal_iput(struct inode* ip); 26 | static int unixfs_internal_igetattr(ino_t ino, struct stat *stbuf); 27 | static void unixfs_internal_istat(struct inode* ip, 28 | struct stat* stbuf); 29 | static int unixfs_internal_namei(ino_t parentino, const char *name, 30 | struct stat* stbuf); 31 | static int unixfs_internal_nextdirentry(struct inode* ip, 32 | struct unixfs_dirbuf* dirbuf, 33 | off_t* offset, 34 | struct unixfs_direntry* dent); 35 | static ssize_t unixfs_internal_pbread(struct inode* ip, char* buf, 36 | size_t nbyte, off_t offset, 37 | int* error); 38 | static int unixfs_internal_sanitycheck(void* filsys, off_t disksize); 39 | static int unixfs_internal_readlink(ino_t ino, 40 | char path[UNIXFS_MAXPATHLEN]); 41 | static int unixfs_internal_statvfs(struct statvfs* svb); 42 | 43 | /* To be used in file-system-specific code. */ 44 | 45 | #define DECL_UNIXFS(fsname, sufx) \ 46 | static struct unixfs_ops ops_##sufx = { \ 47 | .init = unixfs_internal_init, \ 48 | .fini = unixfs_internal_fini, \ 49 | .alloc = unixfs_internal_alloc, \ 50 | .bmap = unixfs_internal_bmap, \ 51 | .bread = unixfs_internal_bread, \ 52 | .iget = unixfs_internal_iget, \ 53 | .iput = unixfs_internal_iput, \ 54 | .igetattr = unixfs_internal_igetattr, \ 55 | .istat = unixfs_internal_istat, \ 56 | .namei = unixfs_internal_namei, \ 57 | .nextdirentry = unixfs_internal_nextdirentry, \ 58 | .pbread = unixfs_internal_pbread, \ 59 | .readlink = unixfs_internal_readlink, \ 60 | .sanitycheck = unixfs_internal_sanitycheck, \ 61 | .statvfs = unixfs_internal_statvfs, \ 62 | }; \ 63 | struct unixfs unixfs_##sufx = { \ 64 | &ops_##sufx, NULL, -1, 0 \ 65 | }; \ 66 | static struct super_block* unixfs = NULL; \ 67 | static const char* unixfs_fstype = fsname; 68 | 69 | #endif /* _UNIXFS_COMMON_H_ */ 70 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/minixfs/.gitignore: -------------------------------------------------------------------------------- 1 | minixfs 2 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/minixfs/Makefile: -------------------------------------------------------------------------------- 1 | # Minix File System Famiy for Mac OS X 2 | # 3 | # Copyright 2008 Amit Singh (osxbook.com). All Rights Reserved. 4 | 5 | TARGETS = minixfs 6 | 7 | # Root for OSXFUSE includes and libraries 8 | OSXFUSE_ROOT = /usr/local 9 | #OSXFUSE_ROOT = /opt/local 10 | 11 | INCLUDE_DIR = $(OSXFUSE_ROOT)/include/osxfuse 12 | LIBRARY_DIR = $(OSXFUSE_ROOT)/lib 13 | 14 | COMMON=../common 15 | UNIXFS=$(COMMON)/unixfs 16 | LINUX=$(COMMON)/linux 17 | LINUX_KERNEL=$(LINUX)/kernel 18 | 19 | CC ?= gcc 20 | 21 | CFLAGS_OSXFUSE = -I$(INCLUDE_DIR) 22 | CFLAGS_OSXFUSE += -D_FILE_OFFSET_BITS=64 23 | CFLAGS_OSXFUSE += -D_DARWIN_USE_64_BIT_INODE 24 | CFLAGS_OSXFUSE += -DFUSE_USE_VERSION=27 25 | CFLAGS_OSXFUSE += -I$(UNIXFS) -I$(LINUX) -I$(LINUX_KERNEL)/include 26 | 27 | CFLAGS_EXTRA = -Wall -Werror -g $(CFLAGS) 28 | 29 | LIBS = -losxfuse 30 | 31 | all: $(TARGETS) 32 | 33 | OBJS = unixfs_minixfs.o minixfs.o minixfs_mainx.o itree_v1.o itree_v2.o 34 | OBJS_COMMON = $(UNIXFS)/unixfs.o $(UNIXFS)/unixfs_internal.o $(LINUX)/linux.o 35 | 36 | minixfs: $(OBJS) $(OBJS_COMMON) 37 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -o $@ $^ -L$(LIBRARY_DIR) $(LIBS) 38 | 39 | -include $(OBJS:.o=.d) 40 | 41 | %.o: %.c 42 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) $*.c -c -o $*.o 43 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -MM $*.c > $*.d 44 | @mv -f $*.d $*.d.tmp 45 | @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d 46 | @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d 47 | @rm -f $*.d.tmp 48 | 49 | clean: 50 | rm -f $(TARGETS) *.o *.d $(UNIXFS)/*.o $(UNIXFS)/*.d $(LINUX)/*.o $(LINUX)/*.d 51 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/minixfs/itree_common.c: -------------------------------------------------------------------------------- 1 | /* Generic part */ 2 | 3 | typedef struct { 4 | block_t* p; 5 | block_t key; 6 | struct buffer_head* bh; 7 | } Indirect; 8 | 9 | static inline void add_chain(Indirect* p, struct buffer_head* bh, block_t* v) 10 | { 11 | p->key = *(p->p = v); 12 | p->bh = bh; 13 | } 14 | 15 | static inline int verify_chain(Indirect* from, Indirect* to) 16 | { 17 | while (from <= to && from->key == *from->p) 18 | from++; 19 | return (from > to); 20 | } 21 | 22 | static inline block_t* block_end(struct buffer_head *bh) 23 | { 24 | return (block_t*)((char*)bh->b_data + bh->b_size); 25 | } 26 | 27 | static inline Indirect* 28 | get_branch(struct inode* inode, int depth, int* offsets, Indirect chain[DEPTH], 29 | int* err) 30 | { 31 | struct super_block* sb = inode->I_sb; 32 | Indirect* p = chain; 33 | struct buffer_head *bh; 34 | 35 | *err = 0; 36 | /* i_data is not going away, no lock needed */ 37 | add_chain (chain, NULL, i_data(inode) + *offsets); 38 | if (!p->key) 39 | goto no_block; 40 | 41 | while (--depth) { 42 | bh = malloc(sizeof(struct buffer_head)); 43 | if (sb_bread_intobh(sb, block_to_cpu(p->key), bh) != 0) 44 | goto failure; 45 | if (!verify_chain(chain, p)) 46 | goto changed; 47 | add_chain(++p, bh, (block_t *)bh->b_data + *++offsets); 48 | if (!p->key) 49 | goto no_block; 50 | } 51 | return NULL; 52 | 53 | changed: 54 | brelse(bh); 55 | *err = -EAGAIN; 56 | goto no_block; 57 | 58 | failure: 59 | *err = -EIO; 60 | 61 | no_block: 62 | return p; 63 | } 64 | 65 | static inline int get_block(struct inode* inode, sector_t iblock, off_t* result) 66 | { 67 | *result = (off_t)0; 68 | 69 | int err = -EIO; 70 | int offsets[DEPTH]; 71 | Indirect chain[DEPTH]; 72 | Indirect* partial; 73 | 74 | int depth = block_to_path(inode, iblock, offsets); 75 | 76 | if (depth == 0) 77 | goto out; 78 | 79 | /* reread: */ 80 | partial = get_branch(inode, depth, offsets, chain, &err); 81 | 82 | /* simplest case - block found, no allocation needed */ 83 | if (!partial) { 84 | *result = (off_t)(block_to_cpu(chain[depth-1].key)); 85 | /* clean up and exit */ 86 | partial = chain + depth - 1; /* the whole chain */ 87 | goto cleanup; 88 | } 89 | 90 | /* Next simple case - plain lookup or failed read of indirect block */ 91 | cleanup: 92 | while (partial > chain) { 93 | brelse(partial->bh); 94 | partial--; 95 | } 96 | 97 | out: 98 | return err; 99 | } 100 | 101 | static inline int all_zeroes(block_t* p, block_t* q) 102 | { 103 | while (p < q) 104 | if (*p++) 105 | return 0; 106 | 107 | return 1; 108 | } 109 | 110 | static inline unsigned nblocks(loff_t size, struct super_block* sb) 111 | { 112 | int k = sb->s_blocksize_bits - 10; 113 | unsigned blocks, res, direct = DIRECT, i = DEPTH; 114 | blocks = (size + sb->s_blocksize - 1) >> (BLOCK_SIZE_BITS + k); 115 | res = blocks; 116 | while (--i && blocks > direct) { 117 | blocks -= direct; 118 | blocks += sb->s_blocksize/sizeof(block_t) - 1; 119 | blocks /= sb->s_blocksize/sizeof(block_t); 120 | res += blocks; 121 | direct = 1; 122 | } 123 | 124 | return res; 125 | } 126 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/minixfs/itree_v1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Minix File System Famiy for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | * 6 | * Most of the code in this file comes from the Linux kernel implementation 7 | * of the minix file system. See fs/minix/ in the Linux kernel source tree. 8 | * 9 | * The code is Copyright (c) its various authors. It is covered by the 10 | * GNU GENERAL PUBLIC LICENSE Version 2. 11 | */ 12 | 13 | #include 14 | #include "minixfs.h" 15 | 16 | enum { DEPTH = 3, DIRECT = 7 }; /* Only double indirect */ 17 | 18 | typedef u16 block_t; /* 16 bit, host order */ 19 | 20 | static inline unsigned long block_to_cpu(block_t n) 21 | { 22 | return n; 23 | } 24 | 25 | #if 0 /* unused */ 26 | static inline block_t cpu_to_block(unsigned long n) 27 | { 28 | return n; 29 | } 30 | #endif /* 0 */ 31 | 32 | static inline block_t* i_data(struct inode* inode) 33 | { 34 | return (block_t *)minix_i(inode)->u.i1_data; 35 | } 36 | 37 | static int block_to_path(struct inode* inode, long block, int offsets[DEPTH]) 38 | { 39 | int n = 0; 40 | 41 | if (block < 0) { 42 | printk("MINIX-fs: block_to_path: block %ld < 0\n", block); 43 | } else if (block >= (minix_sb(inode->I_sb)->s_max_size/BLOCK_SIZE)) { 44 | if (0) 45 | printk("MINIX-fs: block_to_path: block %ld too bign", block); 46 | } else if (block < 7) { 47 | offsets[n++] = block; 48 | } else if ((block -= 7) < 512) { 49 | offsets[n++] = 7; 50 | offsets[n++] = block; 51 | } else { 52 | block -= 512; 53 | offsets[n++] = 8; 54 | offsets[n++] = block >> 9; 55 | offsets[n++] = block & 511; 56 | } 57 | return n; 58 | } 59 | 60 | #include "itree_common.c" 61 | 62 | int 63 | minix_get_block_v1(struct inode* inode, sector_t iblock, off_t* result) 64 | { 65 | return get_block(inode, iblock, result); 66 | } 67 | 68 | unsigned V1_minix_blocks(loff_t size, struct super_block* sb) 69 | { 70 | return nblocks(size, sb); 71 | } 72 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/minixfs/itree_v2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Minix File System Famiy for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | * 6 | * Most of the code in this file comes from the Linux kernel implementation 7 | * of the minix file system. See fs/minix/ in the Linux kernel source tree. 8 | * 9 | * The code is Copyright (c) its various authors. It is covered by the 10 | * GNU GENERAL PUBLIC LICENSE Version 2. 11 | */ 12 | 13 | #include 14 | #include "minixfs.h" 15 | 16 | enum { DIRECT = 7, DEPTH = 4 }; /* Have triple indirect */ 17 | 18 | typedef u32 block_t; /* 32 bit, host order */ 19 | 20 | static inline unsigned long block_to_cpu(block_t n) 21 | { 22 | return n; 23 | } 24 | 25 | #if 0 /* unused */ 26 | static inline block_t cpu_to_block(unsigned long n) 27 | { 28 | return n; 29 | } 30 | #endif /* 0 */ 31 | 32 | static inline block_t* i_data(struct inode* inode) 33 | { 34 | return (block_t*)minix_i(inode)->u.i2_data; 35 | } 36 | 37 | static int block_to_path(struct inode* inode, long block, int offsets[DEPTH]) 38 | { 39 | int n = 0; 40 | struct super_block* sb = inode->I_sb; 41 | 42 | if (block < 0) { 43 | printk("MINIX-fs: block_to_path: block %ld < 0\n", block); 44 | } else if (block >= (minix_sb(inode->I_sb)->s_max_size/sb->s_blocksize)) { 45 | if (0) 46 | printk("MINIX-fs: block_to_path: block %ld too big\n", block); 47 | } else if (block < 7) { 48 | offsets[n++] = block; 49 | } else if ((block -= 7) < 256) { 50 | offsets[n++] = 7; 51 | offsets[n++] = block; 52 | } else if ((block -= 256) < 256 * 256) { 53 | offsets[n++] = 8; 54 | offsets[n++] = block >> 8; 55 | offsets[n++] = block & 255; 56 | } else { 57 | block -= 256 * 256; 58 | offsets[n++] = 9; 59 | offsets[n++] = block >> 16; 60 | offsets[n++] = (block >> 8) & 255; 61 | offsets[n++] = block & 255; 62 | } 63 | return n; 64 | } 65 | 66 | #include "itree_common.c" 67 | 68 | int 69 | minix_get_block_v2(struct inode* inode, sector_t iblock, off_t* result) 70 | { 71 | return get_block(inode, iblock, result); 72 | } 73 | 74 | unsigned V2_minix_blocks(loff_t size, struct super_block* sb) 75 | { 76 | return nblocks(size, sb); 77 | } 78 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/minixfs/minixfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Minix File System Famiy for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | * 6 | * Most of the code in this file comes from the Linux kernel implementation 7 | * of sysvfs. See fs/minix/ in the Linux kernel source tree. 8 | * 9 | * The code is Copyright (c) its various authors. It is covered by the 10 | * GNU GENERAL PUBLIC LICENSE Version 2. 11 | */ 12 | 13 | #ifndef _MINIXFS_H_ 14 | #define _MINIXFS_H_ 15 | 16 | #include "unixfs_internal.h" 17 | #include 18 | #include 19 | #include 20 | 21 | #define INODE_VERSION(inode) minix_sb(inode->I_sb)->s_version 22 | 23 | #define MINIX_V1 0x0001 /* original minix fs */ 24 | #define MINIX_V2 0x0002 /* minix V2 fs */ 25 | #define MINIX_V3 0x0003 /* minix V3 fs */ 26 | 27 | struct minix_inode_info { 28 | union { 29 | __u16 i1_data[16]; 30 | __u32 i2_data[16]; 31 | } u; 32 | u32 i_dir_start_lookup; 33 | }; 34 | 35 | struct minix_sb_info { 36 | unsigned long s_ninodes; 37 | unsigned long s_nzones; 38 | unsigned long s_imap_blocks; 39 | unsigned long s_zmap_blocks; 40 | unsigned long s_firstdatazone; 41 | unsigned long s_log_zone_size; 42 | unsigned long s_max_size; 43 | int s_dirsize; 44 | int s_namelen; 45 | int s_link_max; 46 | struct buffer_head** s_imap; 47 | struct buffer_head** s_zmap; 48 | struct buffer_head* s_sbh; 49 | struct minix_super_block* s_ms; 50 | unsigned short s_mount_state; 51 | unsigned short s_version; 52 | }; 53 | 54 | typedef struct minix_dir_entry minix_dirent; 55 | typedef struct minix3_dir_entry minix3_dirent; 56 | 57 | static inline struct minix_sb_info* minix_sb(struct super_block* sb) 58 | { 59 | return (struct minix_sb_info*)sb->s_fs_info; 60 | } 61 | 62 | static inline struct minix_inode_info* minix_i(struct inode* inode) 63 | { 64 | return (struct minix_inode_info*)inode->I_private; 65 | } 66 | 67 | static inline unsigned long minix_dir_pages(struct inode* inode) 68 | { 69 | return (inode->I_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 70 | } 71 | 72 | static inline int minix_namecompare(int len, int maxlen, const char* name, 73 | const char* buffer) 74 | { 75 | if (len < maxlen && buffer[len]) 76 | return 0; 77 | return !memcmp(name, buffer, len); 78 | } 79 | 80 | #if defined(__LITTLE_ENDIAN__) 81 | #define minix_set_bit(nr,addr) \ 82 | generic___set_le_bit((nr),(unsigned long *)(addr)) 83 | #elif defined(__BIG_ENDIAN__) 84 | #define minix_set_bit(nr,addr) \ 85 | __set_bit((nr),(unsigned long *)(addr)) 86 | #else 87 | #error Endian problem 88 | #endif 89 | 90 | struct super_block* 91 | minixfs_fill_super(int fd, void* args, int silent); 92 | int minixfs_statvfs(struct super_block* sb, struct statvfs* buf); 93 | int minixfs_iget(struct super_block* sb, struct inode* ip); 94 | ino_t minixfs_inode_by_name(struct inode* dir, const char* name); 95 | int minixfs_next_direntry(struct inode* dir, struct unixfs_dirbuf* dirbuf, 96 | off_t* offset, struct unixfs_direntry* dent); 97 | int minixfs_get_block(struct inode* ip, sector_t fragment, off_t* result); 98 | int minixfs_get_page(struct inode* ip, sector_t index, char* pagebuf); 99 | 100 | #endif /* _MINIXFS_H_ */ 101 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/minixfs/minixfs_mainx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Minix File System Famiy for OSXFUSE 3 | * Copyright (c) 2008 Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #include "unixfs.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | static const char* PROGNAME = "minixfs"; 19 | static const char* PROGVERS = "1.0"; 20 | 21 | static struct filesystems { 22 | int isalias; 23 | char* fstypename; 24 | char* fstypename_canonical; 25 | } filesystems[] = { 26 | { 1, "Minix", "minix" }, 27 | { 0, NULL, NULL }, 28 | }; 29 | 30 | __private_extern__ 31 | void 32 | unixfs_usage(void) 33 | { 34 | fprintf(stderr, 35 | "%s (version %s): Minix File System for OSXFUSE\n" 36 | "Amit Singh \n" 37 | "usage:\n" 38 | " %s [--force] --dmg DMG MOUNTPOINT [OSXFUSE args...]\n" 39 | "where:\n" 40 | " . DMG must point to a Minix disk image\n" 41 | " . --force attempts mounting even if there are warnings or errors\n", 42 | PROGNAME, PROGVERS, PROGNAME); 43 | } 44 | 45 | __private_extern__ 46 | struct unixfs* 47 | unixfs_preflight(char* dmg, char** type, struct unixfs** unixfsp) 48 | { 49 | int i; 50 | *unixfsp = NULL; 51 | 52 | if (!type) 53 | goto out; 54 | 55 | *type = "minix"; /* quick fix */ 56 | 57 | for (i = 0; filesystems[i].fstypename != NULL; i++) { 58 | if (strcasecmp(*type, filesystems[i].fstypename) == 0) { 59 | char symb[255]; 60 | snprintf(symb, 255, "%s_%s", "unixfs", 61 | filesystems[i].fstypename_canonical); 62 | void* impl = dlsym(RTLD_DEFAULT, symb); 63 | if (impl != NULL) { 64 | *unixfsp = (struct unixfs*)impl; 65 | break; 66 | } 67 | } 68 | } 69 | 70 | out: 71 | return *unixfsp; 72 | } 73 | 74 | __private_extern__ 75 | void 76 | unixfs_postflight(char* fsname, char* volname, char* extra_args) 77 | { 78 | snprintf(extra_args, UNIXFS_ARGLEN, 79 | "-oro,sparse,defer_permissions,daemon_timeout=5," 80 | "volname=%s,fsname=%s File System", 81 | volname, fsname); 82 | } 83 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/sysvfs/.gitignore: -------------------------------------------------------------------------------- 1 | sysvfs 2 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/sysvfs/Makefile: -------------------------------------------------------------------------------- 1 | # SYSV File System Famiy for OSXFUSE 2 | # 3 | # Copyright 2008 Amit Singh (osxbook.com). All Rights Reserved. 4 | 5 | TARGETS = sysvfs 6 | 7 | # Root for OSXFUSE includes and libraries 8 | OSXFUSE_ROOT = /usr/local 9 | #OSXFUSE_ROOT = /opt/local 10 | 11 | INCLUDE_DIR = $(OSXFUSE_ROOT)/include/osxfuse 12 | LIBRARY_DIR = $(OSXFUSE_ROOT)/lib 13 | 14 | COMMON=../common 15 | UNIXFS=$(COMMON)/unixfs 16 | LINUX=$(COMMON)/linux 17 | LINUX_KERNEL=$(LINUX)/kernel 18 | 19 | CC ?= gcc 20 | 21 | CFLAGS_OSXFUSE = -I$(INCLUDE_DIR) 22 | CFLAGS_OSXFUSE += -I$(UNIXFS) -I$(LINUX) 23 | CFLAGS_OSXFUSE += -DFUSE_USE_VERSION=27 24 | CFLAGS_OSXFUSE += -D_FILE_OFFSET_BITS=64 25 | CFLAGS_OSXFUSE += -D_DARWIN_USE_64_BIT_INODE 26 | 27 | CFLAGS_EXTRA = -Wall -Werror -g $(CFLAGS) 28 | 29 | LIBS = -losxfuse 30 | 31 | all: $(TARGETS) 32 | 33 | OBJS = unixfs_sysvfs.o sysvfs.o sysvfs_mainx.o 34 | OBJS_COMMON = $(UNIXFS)/unixfs.o $(UNIXFS)/unixfs_internal.o $(LINUX)/linux.o 35 | 36 | sysvfs: $(OBJS) $(OBJS_COMMON) 37 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -o $@ $^ -L$(LIBRARY_DIR) $(LIBS) 38 | 39 | -include $(OBJS:.o=.d) 40 | 41 | %.o: %.c 42 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) $(ARCHS) $*.c -c -o $*.o 43 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -MM $*.c > $*.d 44 | @mv -f $*.d $*.d.tmp 45 | @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d 46 | @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d 47 | @rm -f $*.d.tmp 48 | 49 | clean: 50 | rm -f $(TARGETS) *.o *.d $(UNIXFS)/*.o $(UNIXFS)/*.d $(LINUX)/*.o $(LINUX)/*.d 51 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/sysvfs/sysvfs_mainx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SYSV File System Famiy for OSXFUSE 3 | * Copyright (c) 2008 Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #include "unixfs.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | static const char* PROGNAME = "sysvfs"; 19 | static const char* PROGVERS = "1.0"; 20 | 21 | static struct filesystems { 22 | int isalias; 23 | char* fstypename; 24 | char* fstypename_canonical; 25 | } filesystems[] = { 26 | { 1, "sysv", "sysv" }, 27 | { 0, NULL, NULL }, 28 | }; 29 | 30 | __private_extern__ 31 | void 32 | unixfs_usage(void) 33 | { 34 | fprintf(stderr, 35 | "%s (version %s): System V family of file systems for OSXFUSE\n" 36 | "Amit Singh \n" 37 | "usage:\n" 38 | " %s [--force] --dmg DMG MOUNTPOINT [OSXFUSE args...]\n" 39 | "where:\n" 40 | " . DMG must point to a disk image of a valid type; one of:\n" 41 | " SVR4, SVR2, Xenix, Coherent, SCO EAFS, and related\n" 42 | " . --force attempts mounting even if there are warnings or errors\n", 43 | PROGNAME, PROGVERS, PROGNAME); 44 | } 45 | 46 | __private_extern__ 47 | struct unixfs* 48 | unixfs_preflight(char* dmg, char** type, struct unixfs** unixfsp) 49 | { 50 | int i; 51 | *unixfsp = NULL; 52 | 53 | if (!type) 54 | goto out; 55 | 56 | *type = "sysv"; /* quick fix */ 57 | 58 | for (i = 0; filesystems[i].fstypename != NULL; i++) { 59 | if (strcasecmp(*type, filesystems[i].fstypename) == 0) { 60 | char symb[255]; 61 | snprintf(symb, 255, "%s_%s", "unixfs", 62 | filesystems[i].fstypename_canonical); 63 | void* impl = dlsym(RTLD_DEFAULT, symb); 64 | if (impl != NULL) { 65 | *unixfsp = (struct unixfs*)impl; 66 | break; 67 | } 68 | } 69 | } 70 | 71 | out: 72 | return *unixfsp; 73 | } 74 | 75 | __private_extern__ 76 | void 77 | unixfs_postflight(char* fsname, char* volname, char* extra_args) 78 | { 79 | snprintf(extra_args, UNIXFS_ARGLEN, 80 | "-oro,sparse,defer_permissions,daemon_timeout=5," 81 | "volname=%s,fsname=%s File System", 82 | volname, fsname); 83 | } 84 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ufs/.gitignore: -------------------------------------------------------------------------------- 1 | ufs 2 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ufs/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # UFS for OSXFUSE 3 | # Amit Singh 4 | # http://osxbook.com 5 | 6 | TARGETS = ufs 7 | 8 | # Root for OSXFUSE includes and libraries 9 | OSXFUSE_ROOT = /usr/local 10 | #OSXFUSE_ROOT = /opt/local 11 | 12 | INCLUDE_DIR = $(OSXFUSE_ROOT)/include/osxfuse 13 | LIBRARY_DIR = $(OSXFUSE_ROOT)/lib 14 | 15 | COMMON=../common 16 | UNIXFS=$(COMMON)/unixfs 17 | LINUX=$(COMMON)/linux 18 | LINUX_KERNEL=$(LINUX)/kernel 19 | 20 | CC ?= gcc 21 | 22 | CFLAGS_OSXFUSE = -I$(INCLUDE_DIR) 23 | CFLAGS_OSXFUSE += -D_FILE_OFFSET_BITS=64 24 | CFLAGS_OSXFUSE += -D_DARWIN_USE_64_BIT_INODE 25 | CFLAGS_OSXFUSE += -DFUSE_USE_VERSION=27 26 | CFLAGS_OSXFUSE += -I. -I$(LINUX) 27 | CFLAGS_OSXFUSE += -I$(LINUX_KERNEL)/include -I$(LINUX_KERNEL)/fs 28 | CFLAGS_OSXFUSE += -I$(UNIXFS) 29 | 30 | CFLAGS_EXTRA = -Wall -Werror -g $(CFLAGS) 31 | 32 | LIBS = -losxfuse 33 | 34 | all: $(TARGETS) 35 | 36 | OBJS = unixfs_ufs.o ufs_mainx.o ufs.o 37 | OBJS_COMMON = $(UNIXFS)/unixfs.o $(UNIXFS)/unixfs_internal.o $(LINUX)/linux.o $(LINUX_KERNEL)/lib/parser.o 38 | 39 | ufs: $(OBJS) $(OBJS_COMMON) 40 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -o $@ $^ -L$(LIBRARY_DIR) $(LIBS) 41 | 42 | -include $(OBJS:.o=.d) 43 | 44 | %.o: %.c 45 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) $*.c -c -o $*.o 46 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -MM $*.c > $*.d 47 | @mv -f $*.d $*.d.tmp 48 | @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d 49 | @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d 50 | @rm -f $*.d.tmp 51 | 52 | clean: 53 | rm -f $(TARGETS) *.o *.d $(UNIXFS)/*.o $(UNIXFS)/*.d $(LINUX)/*.o $(LINUX)/*.d $(LINUX_KERNEL)/lib/*.o $(LINUX_KERNEL)/lib/*.d 54 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ufs/ufs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UFS for MacFUSE 3 | * Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #ifndef _UFS_H_ 8 | #define _UFS_H_ 9 | 10 | #include "unixfs_internal.h" 11 | #include "linux.h" 12 | 13 | // #define CONFIG_UFS_DEBUG 1 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | struct super_block* 21 | U_ufs_fill_super(int fd, void* args, int silent); 22 | int U_ufs_statvfs(struct super_block* sb, struct statvfs* buf); 23 | int U_ufs_iget(struct super_block* sb, struct inode* ip); 24 | ino_t U_ufs_inode_by_name(struct inode* dir, const char* name); 25 | int U_ufs_next_direntry(struct inode* dir, struct unixfs_dirbuf* dirbuf, 26 | off_t* offset, struct unixfs_direntry* dent); 27 | int U_ufs_get_block(struct inode* ip, sector_t fragment, off_t* result); 28 | int U_ufs_get_page(struct inode* ip, sector_t index, char* pagebuf); 29 | 30 | #endif /* _UFS_H_ */ 31 | -------------------------------------------------------------------------------- /filesystems-c/unixfs/ufs/ufs_mainx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * UFS for OSXFUSE 3 | * Copyright (c) 2008 Amit Singh 4 | * http://osxbook.com 5 | */ 6 | 7 | #include "unixfs.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | static const char* PROGNAME = "ufs"; 19 | static const char* PROGVERS = "1.0"; 20 | 21 | static struct filesystems { 22 | int isalias; 23 | char* fstypename; 24 | char* fstypename_canonical; 25 | } filesystems[] = { 26 | { 0, "old", "ufs" }, 27 | { 0, "sunos", "ufs" }, 28 | { 0, "sun", "ufs" }, 29 | { 0, "sunx86", "ufs" }, 30 | { 0, "hp", "ufs" }, 31 | { 0, "nextstep", "ufs" }, 32 | { 0, "nextstep-cd", "ufs" }, 33 | { 0, "openstep", "ufs" }, 34 | { 0, "44bsd", "ufs" }, 35 | { 0, "5xbsd", "ufs" }, 36 | { 0, "ufs2", "ufs" }, 37 | { 0, NULL, NULL }, 38 | }; 39 | 40 | __private_extern__ 41 | void 42 | unixfs_usage(void) 43 | { 44 | fprintf(stderr, 45 | "%s (version %s): UFS family of file systems for OSXFUSE\n" 46 | "Amit Singh \n" 47 | "usage:\n" 48 | " %s [--force] --dmg DMG --type TYPE MOUNTPOINT [OSXFUSE args...]\n" 49 | "where:\n" 50 | " . DMG must point to an ancient Unix disk image of a valid type\n" 51 | " . TYPE is one of:", 52 | PROGNAME, PROGVERS, PROGNAME); 53 | 54 | int i; 55 | for (i = 0; filesystems[i].fstypename != NULL; i++) { 56 | if (!filesystems[i].isalias) 57 | fprintf(stderr, " %s ", filesystems[i].fstypename); 58 | } 59 | fprintf(stderr, "\n"); 60 | 61 | fprintf(stderr, "%s", 62 | " . --force attempts mounting even if there are warnings or errors\n" 63 | ); 64 | } 65 | 66 | __private_extern__ 67 | struct unixfs* 68 | unixfs_preflight(char* dmg, char** type, struct unixfs** unixfsp) 69 | { 70 | int i; 71 | *unixfsp = NULL; 72 | 73 | if (!type || !*type) 74 | goto out; 75 | 76 | for (i = 0; filesystems[i].fstypename != NULL; i++) { 77 | if (strcasecmp(*type, filesystems[i].fstypename) == 0) { 78 | char symb[255]; 79 | snprintf(symb, 255, "%s_%s", "unixfs", 80 | filesystems[i].fstypename_canonical); 81 | void* impl = dlsym(RTLD_DEFAULT, symb); 82 | if (impl != NULL) { 83 | *unixfsp = (struct unixfs*)impl; 84 | break; 85 | } 86 | } 87 | } 88 | 89 | out: 90 | return *unixfsp; 91 | } 92 | 93 | __private_extern__ 94 | void 95 | unixfs_postflight(char* fsname, char* volname, char* extra_args) 96 | { 97 | snprintf(extra_args, UNIXFS_ARGLEN, 98 | "-oro,sparse,defer_permissions,daemon_timeout=5," 99 | "volname=%s,fsname=%s File System", 100 | volname, fsname); 101 | } 102 | -------------------------------------------------------------------------------- /filesystems-c/verybigfs/.gitignore: -------------------------------------------------------------------------------- 1 | *.dSYM/ 2 | *.a 3 | *.dylib 4 | *.o 5 | 6 | .DS_Store 7 | verybigfs 8 | -------------------------------------------------------------------------------- /filesystems-c/verybigfs/Makefile: -------------------------------------------------------------------------------- 1 | # A "very big" file system with a "very big" file. All that you can read. 2 | # 3 | # Copyright 2008 Amit Singh (osxbook.com). All Rights Reserved. 4 | # 5 | # Source License: GNU GENERAL PUBLIC LICENSE (GPL) 6 | 7 | TARGETS = verybigfs 8 | 9 | # Root for OSXFUSE includes and libraries 10 | OSXFUSE_ROOT = /usr/local 11 | #OSXFUSE_ROOT = /opt/local 12 | 13 | INCLUDE_DIR = $(OSXFUSE_ROOT)/include/osxfuse/fuse 14 | LIBRARY_DIR = $(OSXFUSE_ROOT)/lib 15 | 16 | CC ?= gcc 17 | 18 | CFLAGS_OSXFUSE = -I$(INCLUDE_DIR) -L$(LIBRARY_DIR) 19 | CFLAGS_OSXFUSE += -DFUSE_USE_VERSION=26 20 | CFLAGS_OSXFUSE += -D_FILE_OFFSET_BITS=64 21 | CFLAGS_OSXFUSE += -D_DARWIN_USE_64_BIT_INODE 22 | 23 | CFLAGS_EXTRA = -Wall -g $(CFLAGS) 24 | 25 | LIBS = -losxfuse 26 | 27 | .c: 28 | $(CC) $(CFLAGS_OSXFUSE) $(CFLAGS_EXTRA) -o $@ $< $(LIBS) 29 | 30 | all: $(TARGETS) 31 | 32 | verybigfs: verybigfs.c 33 | 34 | clean: 35 | rm -f $(TARGETS) *.o 36 | rm -rf *.dSYM 37 | -------------------------------------------------------------------------------- /filesystems-c/verybigfs/verybigfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * A "very big" file system with a "very big" file. All that you can read. 3 | * 4 | * Copyright Amit Singh. All Rights Reserved. 5 | * http://osxbook.com 6 | * 7 | * http://code.google.com/p/macfuse/ 8 | * 9 | * Source License: GNU GENERAL PUBLIC LICENSE (GPL) 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | char *bigfile_path = "/copyme.txt"; 19 | 20 | static int 21 | verybigfs_statfs(const char *path, struct statvfs *stbuf) 22 | { 23 | stbuf->f_bsize = 1024 * 1024; /* 1MB */ 24 | stbuf->f_frsize = 128 * 1024; /* MAXPHYS */ 25 | stbuf->f_blocks = 0xFFFFFFFFUL; /* aim for a lot; this is 32-bit though */ 26 | stbuf->f_bfree = stbuf->f_bavail = stbuf->f_ffree = stbuf->f_favail = 0; 27 | stbuf->f_files = 3; 28 | return 0; 29 | } 30 | 31 | static int 32 | verybigfs_getattr(const char *path, struct stat *stbuf) 33 | { 34 | memset(stbuf, 0, sizeof(struct stat)); 35 | stbuf->st_atime = stbuf->st_ctime = stbuf->st_mtime = time(NULL); 36 | stbuf->st_uid = getuid(); 37 | if (strcmp(path, "/") == 0) { 38 | stbuf->st_mode = S_IFDIR | 0755; 39 | stbuf->st_nlink = 2; 40 | } else if (strcmp(path, bigfile_path) == 0) { 41 | stbuf->st_mode = S_IFREG | 0444; 42 | stbuf->st_nlink = 1; 43 | stbuf->st_size = 128ULL * 1024ULL * 0xFFFFFFFFULL; 44 | } else 45 | return -ENOENT; 46 | return 0; 47 | } 48 | 49 | static int 50 | verybigfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, 51 | off_t offset, struct fuse_file_info *fi) 52 | { 53 | filler(buf, ".", NULL, 0); 54 | filler(buf, "..", NULL, 0); 55 | filler(buf, bigfile_path + 1, NULL, 0); 56 | return 0; 57 | } 58 | 59 | static int 60 | verybigfs_read(const char *path, char *buf, size_t size, off_t offset, 61 | struct fuse_file_info *fi) 62 | { 63 | return 0; 64 | } 65 | 66 | static struct fuse_operations verybigfs_oper = { 67 | .getattr = verybigfs_getattr, 68 | .read = verybigfs_read, 69 | .readdir = verybigfs_readdir, 70 | .statfs = verybigfs_statfs, 71 | }; 72 | 73 | int 74 | main(int argc, char *argv[]) 75 | { 76 | return fuse_main(argc, argv, &verybigfs_oper, NULL); 77 | } 78 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1 2 | *.mode1v3 3 | *.mode2v3 4 | *.perspective 5 | *.perspectivev3 6 | *.pbxuser 7 | 8 | build/ 9 | project.xcworkspace/ 10 | xcuserdata/ 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/AccessibilityFS_Prefix.pch: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // Prefix header for all source files of the 'AccessibilityFS' target in the 18 | // 'AccessibilityFS' project 19 | // 20 | 21 | #ifdef __OBJC__ 22 | #import 23 | #endif 24 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/ReadMe.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Resources/AccessibilityFSApp.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/AccessibilityFS/Resources/AccessibilityFSApp.icns -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Resources/AccessibilityFSMount.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/AccessibilityFS/Resources/AccessibilityFSMount.icns -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Resources/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/AccessibilityFS/Resources/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Resources/English.lproj/MainMenu.nib/classes.nib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IBClasses 6 | 7 | 8 | CLASS 9 | FirstResponder 10 | LANGUAGE 11 | ObjC 12 | SUPERCLASS 13 | NSObject 14 | 15 | 16 | CLASS 17 | AccessibilityController 18 | LANGUAGE 19 | ObjC 20 | SUPERCLASS 21 | NSObject 22 | 23 | 24 | IBVersion 25 | 1 26 | 27 | 28 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Resources/English.lproj/MainMenu.nib/info.nib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IBFramework Version 6 | 629 7 | IBLastKnownRelativeProjectPath 8 | ../../../AccessibilityFS.xcodeproj 9 | IBOldestOS 10 | 5 11 | IBOpenObjects 12 | 13 | IBSystem Version 14 | 9B18 15 | targetFramework 16 | IBCocoaFramework 17 | 18 | 19 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Resources/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/AccessibilityFS/Resources/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleGetInfoString 10 | AccessibilityFS 0.6 11 | CFBundleIconFile 12 | AccessibilityFSApp 13 | CFBundleIdentifier 14 | com.google.fuse.AccessibilityFS 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 0.6 25 | FUSEFileSystemClass 26 | AccessibilityFS 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Source/AccessibilityController.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // AccessibilityController.h 18 | // AccessibilityFS 19 | /// 20 | 21 | #import 22 | 23 | @class GMUserFileSystem; 24 | 25 | @interface AccessibilityController : NSObject { 26 | GMUserFileSystem* fs_; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Source/AccessibilityController.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // AccessibilityController.m 18 | // AccessibilityFS 19 | // 20 | 21 | #import "AccessibilityController.h" 22 | #import "AccessibilityFS.h" 23 | #import 24 | #import "GTMAXUIElement.h" 25 | 26 | NSString *const kMountPath = @"/Volumes/Accessibility"; 27 | 28 | @implementation AccessibilityController 29 | 30 | - (void)applicationDidBecomeActive:(NSNotification *)notification { 31 | NSString* parentPath = [kMountPath stringByDeletingLastPathComponent]; 32 | [[NSWorkspace sharedWorkspace] selectFile:kMountPath 33 | inFileViewerRootedAtPath:parentPath]; 34 | } 35 | 36 | - (void)didMount:(NSNotification *)notification { 37 | [self applicationDidBecomeActive:notification]; 38 | } 39 | 40 | - (void)didUnmount:(NSNotification*)notification { 41 | [[NSApplication sharedApplication] terminate:nil]; 42 | } 43 | 44 | - (void)applicationDidFinishLaunching:(NSNotification *)notification { 45 | if (![GTMAXUIElement isAccessibilityEnabled]) { 46 | NSAlert *alert = [[[NSAlert alloc] init] autorelease]; 47 | [alert setMessageText:NSLocalizedString(@"Can't start AccessibilityFS", 48 | @"Can't start error")]; 49 | [alert setInformativeText:NSLocalizedString(@"Please 'Enable access for assistive devices' in the 'Universal Access' System preference panel.", 50 | @"Can't start help")]; 51 | [alert runModal]; 52 | [NSApp terminate:self]; 53 | } 54 | NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 55 | [center addObserver:self selector:@selector(didMount:) 56 | name:kGMUserFileSystemDidMount object:nil]; 57 | [center addObserver:self selector:@selector(didUnmount:) 58 | name:kGMUserFileSystemDidUnmount object:nil]; 59 | 60 | fs_ = [[GMUserFileSystem alloc] initWithDelegate:[[AccessibilityFS alloc] init] 61 | isThreadSafe:NO]; 62 | 63 | NSMutableArray* options = [NSMutableArray array]; 64 | NSString* volArg = 65 | [NSString stringWithFormat:@"volicon=%@", 66 | [[NSBundle mainBundle] pathForResource:@"AccessibilityFSMount" ofType:@"icns"]]; 67 | [options addObject:volArg]; 68 | [options addObject:@"volname=Accessibility"]; 69 | // Turn on for tons of fun debugging spew 70 | // [options addObject:@"debug"]; 71 | [fs_ mountAtPath:kMountPath 72 | withOptions:options]; 73 | } 74 | 75 | - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { 76 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 77 | [fs_ unmount]; 78 | id delegate = [fs_ delegate]; 79 | [fs_ release]; 80 | [delegate release]; 81 | return NSTerminateNow; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Source/AccessibilityFS.h: -------------------------------------------------------------------------------- 1 | // 2 | // AccessibilityFS.h 3 | // AccessibilityFS 4 | // 5 | // Created by Dave MacLachlan on 12/14/07. 6 | // 7 | // ================================================================ 8 | // Copyright (C) 2008 Google Inc. 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | // ================================================================ 22 | 23 | #import 24 | 25 | // A MacFUSE file system for probing around through various applications' 26 | // UIs exposed through Accessibility. 27 | @interface AccessibilityFS : NSObject { 28 | @private 29 | // A collection of info about processes keyed by their GMAXUIElement. 30 | NSMutableDictionary *appDictionary_; 31 | 32 | // The last time root was modified due to an app launching or terminating. 33 | NSDate *rootModifiedDate_; 34 | } 35 | @end 36 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Source/command_main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * command_main.c 3 | * AccessibilityFS 4 | * 5 | * Created by Dave MacLachlan on 2007/12/13. 6 | * 7 | */ 8 | 9 | // ================================================================ 10 | // Copyright (C) 2008 Google Inc. 11 | // 12 | // Licensed under the Apache License, Version 2.0 (the "License"); 13 | // you may not use this file except in compliance with the License. 14 | // You may obtain a copy of the License at 15 | // 16 | // http://www.apache.org/licenses/LICENSE-2.0 17 | // 18 | // Unless required by applicable law or agreed to in writing, software 19 | // distributed under the License is distributed on an "AS IS" BASIS, 20 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | // See the License for the specific language governing permissions and 22 | // limitations under the License. 23 | // ================================================================ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | typedef struct { 32 | const char* command; 33 | const char* axcommand; 34 | } CommandMap; 35 | 36 | const CommandMap kMap [] = { 37 | { "cancel", "AXCancel" }, 38 | { "confirm", "AXConfirm" }, 39 | { "decrement", "AXDecrement" }, 40 | { "increment", "AXIncrement" }, 41 | { "press", "AXPress" }, 42 | { "raise", "AXRaise" }, 43 | { "showmenu", "AXShowMenu" }, 44 | }; 45 | 46 | void showDocumentation() { 47 | fprintf(stderr, "ax_command \nwhere command is one of:\n"); 48 | for (int i = 0; i < sizeof(kMap) / sizeof(CommandMap); ++i) { 49 | fprintf(stderr, "%s\n", kMap[i].command); 50 | } 51 | } 52 | 53 | int main(int argc, char** argv) { 54 | if (argc != 3) { 55 | showDocumentation(); 56 | return -1; 57 | } 58 | 59 | const char *command = NULL; 60 | for (int i = 0; i < sizeof(kMap) / sizeof(CommandMap); ++i) { 61 | if (strcasecmp(argv[1], kMap[i].command) == 0) { 62 | command = kMap[i].axcommand; 63 | break; 64 | } 65 | } 66 | if (!command) { 67 | showDocumentation(); 68 | return -1; 69 | } 70 | 71 | int file = open(argv[2], O_WRONLY); 72 | if (file == -1) { 73 | showDocumentation(); 74 | fprintf(stderr, "Unable to open file %s (%d)\n", argv[2], errno); 75 | return errno; 76 | } 77 | ssize_t size = write(file, command, strlen(command)); 78 | if (size == -1) { 79 | showDocumentation(); 80 | fprintf(stderr, "Unable to perform %s (%d)\n", command, errno); 81 | close(file); 82 | return errno; 83 | } 84 | 85 | return close(file); 86 | 87 | 88 | } -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Source/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AccessibiliyFS 4 | // 5 | // ================================================================ 6 | // Copyright (C) 2008 Google Inc. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | // ================================================================ 20 | 21 | #import 22 | 23 | int main(int argc, char *argv[]) { 24 | return NSApplicationMain(argc, (const char **) argv); 25 | } 26 | -------------------------------------------------------------------------------- /filesystems-objc/AccessibilityFS/Toolbox/GTMAXUIElement.h: -------------------------------------------------------------------------------- 1 | // 2 | // GTMAXUIElement.h 3 | // AccessibilityFS 4 | // 5 | // Created by Dave MacLachlan on 2008/01/11. 6 | // ================================================================ 7 | // Copyright (C) 2008 Google Inc. 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // ================================================================ 21 | 22 | #import 23 | 24 | // A objc wrapper for a AXUIElement. 25 | // We implement hash and isEqual so they can be used as keys. 26 | @interface GTMAXUIElement : NSObject { 27 | AXUIElementRef element_; 28 | } 29 | 30 | // Returns true if this app can use accessibility. Checks to see if API is 31 | // enabled or this process is trusted. If this does not return true, all 32 | // of the methods below will fail in weird and wonderful ways. 33 | + (BOOL)isAccessibilityEnabled; 34 | 35 | // Returns a GTMAXUIElement for the system wide element 36 | + (id)systemWideElement; 37 | 38 | // Returns a GTMAXUIElement for the given element 39 | + (id)elementWithElement:(AXUIElementRef)element; 40 | 41 | // Returns a GTMAXUIElement for the given process 42 | + (id)elementWithProcessIdentifier:(pid_t)pid; 43 | 44 | // Initialized as the element for the current process 45 | - (id)init; 46 | 47 | // Initialized with the given element (designated initializer) 48 | - (id)initWithElement:(AXUIElementRef)element; 49 | 50 | // Initialized wih the element for the pid. 51 | - (id)initWithProcessIdentifier:(pid_t)pid; 52 | 53 | // Returns the element we are wrapping. 54 | - (AXUIElementRef)element; 55 | 56 | // Attributes 57 | // Returns the list of supported attribute names 58 | - (NSArray*)accessibilityAttributeNames; 59 | 60 | // Returns value for attribute. 61 | // If attribute has no value returns NSNull. 62 | // Returns nil on error. 63 | - (id)accessibilityAttributeValue:(NSString*)attribute; 64 | 65 | // Returns YES is attribute is settable 66 | - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute; 67 | 68 | // Returns YES if attribute is set to value 69 | - (BOOL)setAccessibilityValue:(CFTypeRef)value forAttribute:(NSString*)attribute; 70 | 71 | // Returns the number of values in the array of the atribute returns an array. 72 | // Returns -1 on error. 73 | - (int)accessibilityAttributeValueCount:(NSString*)attribute; 74 | 75 | // parameterized attribute methods 76 | // Returns the list of supported parameterized attributes 77 | - (NSArray *)accessibilityParameterizedAttributeNames; 78 | // 79 | // Returns the value for a parameterized attribute. 80 | // If attribute has no value, returns NSNull. 81 | // returns nil on error 82 | - (id)accessibilityAttributeValue:(NSString *)attribute forParameter:(id)parameter; 83 | 84 | // action methods 85 | // Returns the list of actions supported by the element 86 | - (NSArray *)accessibilityActionNames; 87 | // Returns a localized name of the action description 88 | - (NSString *)accessibilityActionDescription:(NSString *)action; 89 | // Returns YES if action is performed. 90 | - (BOOL)performAccessibilityAction:(NSString *)action; 91 | 92 | // Returns a string value for the given attribute if possible. 93 | - (NSString*)stringValueForAttribute:(NSString*)attribute; 94 | 95 | // Sets a value for the given attribute if possible. Returns YES on success. 96 | - (BOOL)setStringValue:(NSString*)string forAttribute:(NSString*)attribute; 97 | 98 | // Processes 99 | // Returns the pid for the parent process of theelement. 100 | - (pid_t)processIdentifier; 101 | // Returns a GMAXUIElement wrappiung the parent process of the element. 102 | - (GTMAXUIElement*)processElement; 103 | @end -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1 2 | *.mode1v3 3 | *.mode2v3 4 | *.perspective 5 | *.perspectivev3 6 | *.pbxuser 7 | 8 | build/ 9 | project.xcworkspace/ 10 | xcuserdata/ 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/HelloFS/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/HelloFS/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/HelloController.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // HelloController.h 18 | // HelloFS 19 | // 20 | // Created by ted on 1/3/08. 21 | // 22 | #import 23 | 24 | @class GMUserFileSystem; 25 | 26 | @interface HelloController : NSObject { 27 | GMUserFileSystem* fs_; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/HelloController.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // HelloController 18 | // HelloFS 19 | // 20 | // Created by ted on 1/3/08. 21 | // 22 | #import "HelloController.h" 23 | #import "HelloFuseFileSystem.h" 24 | #import 25 | 26 | @implementation HelloController 27 | 28 | - (void)didMount:(NSNotification *)notification { 29 | NSDictionary* userInfo = [notification userInfo]; 30 | NSString* mountPath = [userInfo objectForKey:kGMUserFileSystemMountPathKey]; 31 | NSString* parentPath = [mountPath stringByDeletingLastPathComponent]; 32 | [[NSWorkspace sharedWorkspace] selectFile:mountPath 33 | inFileViewerRootedAtPath:parentPath]; 34 | } 35 | 36 | - (void)didUnmount:(NSNotification*)notification { 37 | [[NSApplication sharedApplication] terminate:nil]; 38 | } 39 | 40 | - (void)applicationDidFinishLaunching:(NSNotification *)notification { 41 | NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 42 | [center addObserver:self selector:@selector(didMount:) 43 | name:kGMUserFileSystemDidMount object:nil]; 44 | [center addObserver:self selector:@selector(didUnmount:) 45 | name:kGMUserFileSystemDidUnmount object:nil]; 46 | 47 | NSString* mountPath = @"/Volumes/Hello"; 48 | HelloFuseFileSystem* hello = [[HelloFuseFileSystem alloc] init]; 49 | fs_ = [[GMUserFileSystem alloc] initWithDelegate:hello isThreadSafe:YES]; 50 | NSMutableArray* options = [NSMutableArray array]; 51 | [options addObject:@"rdonly"]; 52 | [options addObject:@"volname=HelloFS"]; 53 | [options addObject:[NSString stringWithFormat:@"volicon=%@", 54 | [[NSBundle mainBundle] pathForResource:@"Fuse" ofType:@"icns"]]]; 55 | [fs_ mountAtPath:mountPath withOptions:options]; 56 | } 57 | 58 | - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { 59 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 60 | [fs_ unmount]; // Just in case we need to unmount; 61 | [[fs_ delegate] release]; // Clean up HelloFS 62 | [fs_ release]; 63 | return NSTerminateNow; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/HelloFS_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'HelloFS' target in the 'HelloFS' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/HelloFuseFileSystem.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2006 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // HelloFuseFileSystem.h 18 | // 19 | // Created by alcor on 12/15/06. 20 | // 21 | 22 | #import 23 | 24 | @interface HelloFuseFileSystem : NSObject 25 | @end 26 | -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/HelloFuseFileSystem.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2006 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // HelloFuseFileSystem.m 18 | // GoogleHelloFuse 19 | // 20 | // Created by alcor on 12/15/06. 21 | // 22 | #import "HelloFuseFileSystem.h" 23 | #import 24 | 25 | static NSString *helloStr = @"Hello World!\n"; 26 | static NSString *helloPath = @"/hello.txt"; 27 | 28 | @implementation HelloFuseFileSystem 29 | 30 | - (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error { 31 | return [NSArray arrayWithObject:[helloPath lastPathComponent]]; 32 | } 33 | 34 | - (NSData *)contentsAtPath:(NSString *)path { 35 | if ([path isEqualToString:helloPath]) 36 | return [helloStr dataUsingEncoding:NSUTF8StringEncoding]; 37 | return nil; 38 | } 39 | 40 | #pragma optional Custom Icon 41 | 42 | - (NSDictionary *)finderAttributesAtPath:(NSString *)path 43 | error:(NSError **)error { 44 | if ([path isEqualToString:helloPath]) { 45 | NSNumber* finderFlags = [NSNumber numberWithLong:kHasCustomIcon]; 46 | return [NSDictionary dictionaryWithObject:finderFlags 47 | forKey:kGMUserFileSystemFinderFlagsKey]; 48 | } 49 | return nil; 50 | } 51 | 52 | - (NSDictionary *)resourceAttributesAtPath:(NSString *)path 53 | error:(NSError **)error { 54 | if ([path isEqualToString:helloPath]) { 55 | NSString *file = [[NSBundle mainBundle] pathForResource:@"hellodoc" ofType:@"icns"]; 56 | return [NSDictionary dictionaryWithObject:[NSData dataWithContentsOfFile:file] 57 | forKey:kGMUserFileSystemCustomIconDataKey]; 58 | } 59 | return nil; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.HelloFS 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/Resources/Fuse.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/HelloFS/Resources/Fuse.icns -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/Resources/hellodoc.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/HelloFS/Resources/hellodoc.icns -------------------------------------------------------------------------------- /filesystems-objc/HelloFS/main.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // main.m 18 | // HelloFS 19 | // 20 | // Created by ted on 1/3/08. 21 | // 22 | #import 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | return NSApplicationMain(argc, (const char **) argv); 27 | } 28 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1 2 | *.mode1v3 3 | *.mode2v3 4 | *.perspective 5 | *.perspectivev3 6 | *.pbxuser 7 | 8 | build/ 9 | project.xcworkspace/ 10 | xcuserdata/ 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/LoopbackFS/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.LoopbackFS 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/LoopbackController.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2007 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // LoopbackController.h 18 | // LoopbackFS 19 | // 20 | // Created by ted on 12/27/07. 21 | // 22 | 23 | #import 24 | 25 | @class GMUserFileSystem; 26 | @class LoopbackFS; 27 | 28 | @interface LoopbackController : NSObject { 29 | GMUserFileSystem* fs_; 30 | LoopbackFS* loop_; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/LoopbackFS.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.cs.disable-library-validation 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/LoopbackFS.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2007 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // LoopbackFS.h 18 | // LoopbackFS 19 | // 20 | // Created by ted on 12/12/07. 21 | // 22 | // This is a simple but complete example filesystem that mounts a local 23 | // directory. You can modify this to see how the Finder reacts to returning 24 | // specific error codes or not implementing a particular GMUserFileSystem 25 | // operation. 26 | // 27 | // For example, you can mount "/tmp" in /Volumes/loop. Note: It is 28 | // probably not a good idea to mount "/" through this filesystem. 29 | 30 | #import 31 | 32 | @interface LoopbackFS : NSObject { 33 | NSString* rootPath_; // The local file-system path to mount. 34 | } 35 | - (id)initWithRootPath:(NSString *)rootPath; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/LoopbackFS.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/LoopbackFS/LoopbackFS.icns -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/LoopbackFS_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'LoopbackFS' target in the 'LoopbackFS' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/README.txt: -------------------------------------------------------------------------------- 1 | LoopBackFS 2 | 3 | This is a simple but complete example filesystem that mounts a local 4 | directory. You can modify this to see how the Finder reacts to returning 5 | specific error codes or not implementing a particular UserFileSystem 6 | operation. 7 | 8 | For example, you can mount "/tmp" in /Volumes/loop. Note: It is 9 | probably not a good idea to mount "/" through this filesystem. 10 | 11 | You can build a .app version from LoopbackFS.xcodeproj and a standalone 12 | command line version using: 13 | 14 | gcc -o loop ../Support/NSError+POSIX.m LoopbackFS.m loop.m -I../Support \ 15 | -framework MacFUSE -framework Foundation 16 | 17 | This will create a binary called "loop" in the current directory. 18 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/loop.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -s 2 | 3 | #pragma D option quiet 4 | #pragma D option bufsize=16k 5 | 6 | macfuse_objc*:::delegate-entry 7 | /execname == "LoopbackFS"/ 8 | { 9 | printf("%-14d %s: %s\r\n", timestamp, probefunc, copyinstr(arg0)); 10 | } 11 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/loop.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2007 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // loop.m 18 | // LoopbackFS 19 | // 20 | // Created by ted on 12/30/07. 21 | // 22 | // This is a cmdline version of LoopbackFS. Compile as follows: 23 | // gcc -o loop LoopbackFS.m loop.m -framework MacFUSE -framework Foundation 24 | // 25 | #import 26 | #import 27 | #import "LoopbackFS.h" 28 | 29 | #define DEFAULT_MOUNT_PATH "/Volumes/loop" 30 | 31 | int main(int argc, char* argv[]) { 32 | NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 33 | 34 | NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; 35 | NSString* rootPath = [args stringForKey:@"rootPath"]; 36 | NSString* mountPath = [args stringForKey:@"mountPath"]; 37 | if (!mountPath || [mountPath isEqualToString:@""]) { 38 | mountPath = [NSString stringWithUTF8String:DEFAULT_MOUNT_PATH]; 39 | } 40 | if (!rootPath) { 41 | printf("\nUsage: %s -rootPath [-mountPath ]\n", argv[0]); 42 | printf(" -rootPath: Local directory path to mount, ex: /tmp\n"); 43 | printf(" -mountPath: Mount point to use. [Default='%s']\n", 44 | DEFAULT_MOUNT_PATH); 45 | printf("Ex: %s -rootPath /tmp -mountPath %s\n\n", argv[0], 46 | DEFAULT_MOUNT_PATH); 47 | return 0; 48 | } 49 | 50 | LoopbackFS* loop = [[LoopbackFS alloc] initWithRootPath:rootPath]; 51 | GMUserFileSystem* userFS = [[GMUserFileSystem alloc] initWithDelegate:loop 52 | isThreadSafe:YES]; 53 | 54 | NSMutableArray* options = [NSMutableArray array]; 55 | [options addObject:@"debug"]; 56 | [userFS mountAtPath:mountPath 57 | withOptions:options 58 | shouldForeground:YES 59 | detachNewThread:NO]; 60 | 61 | [userFS release]; 62 | [loop release]; 63 | 64 | [pool release]; 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /filesystems-objc/LoopbackFS/main.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2007 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // main.m 18 | // LoopbackFS 19 | // 20 | // Created by ted on 12/27/07. 21 | // 22 | #import 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | return NSApplicationMain(argc, (const char **) argv); 27 | } 28 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1 2 | *.mode1v3 3 | *.mode2v3 4 | *.perspective 5 | *.perspectivev3 6 | *.pbxuser 7 | 8 | build/ 9 | project.xcworkspace/ 10 | xcuserdata/ 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/DynamicFolderBlue.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/SpotlightFS/Resources/DynamicFolderBlue.icns -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/SpotlightFS/Resources/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/English.lproj/MainMenu.nib/classes.nib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IBClasses 6 | 7 | 8 | CLASS 9 | SpotlightFSController 10 | LANGUAGE 11 | ObjC 12 | SUPERCLASS 13 | NSObject 14 | 15 | 16 | CLASS 17 | FirstResponder 18 | LANGUAGE 19 | ObjC 20 | SUPERCLASS 21 | NSObject 22 | 23 | 24 | IBVersion 25 | 1 26 | 27 | 28 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/English.lproj/MainMenu.nib/info.nib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IBFramework Version 6 | 629 7 | IBLastKnownRelativeProjectPath 8 | ../../../SpotlightFS.xcodeproj 9 | IBOldestOS 10 | 5 11 | IBOpenObjects 12 | 13 | IBSystem Version 14 | 9B18 15 | targetFramework 16 | IBCocoaFramework 17 | 18 | 19 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/SpotlightFS/Resources/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleGetInfoString 10 | SpotlightFS 0.1.1 11 | CFBundleIconFile 12 | SpotlightFSApp 13 | CFBundleIdentifier 14 | com.google.fuse.SpotlightFS 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 0.1.1 25 | LSUIElement 26 | 1 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/SmartFolder.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/SpotlightFS/Resources/SmartFolder.icns -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/SmartFolderBlue.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/SpotlightFS/Resources/SmartFolderBlue.icns -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/SpotlightFSApp.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/SpotlightFS/Resources/SpotlightFSApp.icns -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Resources/SpotlightFSMount.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/SpotlightFS/Resources/SpotlightFSMount.icns -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Source/SpotlightFS.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2007 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // SpotlightFS.h 18 | // SpotlightFS 19 | // 20 | // Created by Greg Miller on 1/19/07. 21 | // 22 | #import 23 | 24 | // A MacFUSE file system for creating real smart folders. The SpotlightFS 25 | // file system may consist of some top-level directories, and each of these 26 | // directories contain symbolic links to files matching some Spotlight query. 27 | // 28 | // In the simplest case, the Spotlight query used to generate the contents of 29 | // a directory is simply the name of the diretory itself. For example, a 30 | // directory named /Volumes/SpotlightFS/foo would contain symbolic links to 31 | // all files that match a Spotlight query for the word "foo". 32 | // 33 | // Additionally, SpotlightFS looks in "~/Library/Saved Searches" for all files 34 | // with a ".savedSearch" extension, and automatically creates top-level 35 | // directories for these files. The Spotlight query which generates the 36 | // contents for these directories is found by reading the "RawQuery" key from 37 | // the saved search plist. 38 | // 39 | // See the documentation for FUSEFileSystem for more details. 40 | // 41 | @interface SpotlightFS : NSObject { 42 | // Empty 43 | } 44 | 45 | // Returns an array of all *.savedSearch files in "~/Library/Saved Searches". 46 | // The returned paths have the ".savedSearch" extension removed. If no 47 | // saved searches are found, then an empty array is returned rather than nil. 48 | // 49 | - (NSArray *)spotlightSavedSearches; 50 | 51 | // Returns a dictionary with the contents of the saved search file named "name", 52 | // or "name.savedSearch". 53 | // 54 | - (NSDictionary *)contentsOfSpotlightSavedSearchNamed:(NSString *)name; 55 | 56 | // Returns all the user-created search folders. 57 | // 58 | - (NSArray *)userCreatedFolders; 59 | 60 | // Returns YES if |path| is a user created folder. 61 | // 62 | - (BOOL)isUserCreatedFolder:(NSString *)path; 63 | 64 | // Sets the full user-created folders array. 65 | // 66 | - (void)setUserCreatedFolders:(NSArray *)folders; 67 | 68 | // Adds one search (i.e. directory name) to the list of user-created folders. 69 | // As an example, "mkdir /Volumes/SpotlightFS/foo" will ultimately call through 70 | // to this method to create the user-defined search for "foo". 71 | // 72 | - (void)addUserCreatedFolder:(NSString *)folder; 73 | 74 | // Remove a user-defined search. 75 | // 76 | - (void)removeUserCreatedFolder:(NSString *)folder; 77 | 78 | // Returns the concatenation of -spotlightSavedSearches and -userCreatedFolderes 79 | // 80 | - (NSArray *)topLevelDirectories; 81 | 82 | // Runs the Spotlight query specified by "queryString", and returns the paths 83 | // for all the matching files. The returned paths are encoded, meaning that 84 | // all forward slashes have been replaced by colons. 85 | // 86 | - (NSArray *)encodedPathResultsForSpotlightQuery:(NSString *)queryString 87 | scope:(NSArray *)scopeDirectories; 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Source/SpotlightFSController.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // SpotlightFSController.h 18 | // SpotlightFS 19 | // 20 | // Created by ted on 1/3/08. 21 | // 22 | 23 | #import 24 | #import "SpotlightFS.h" 25 | 26 | @class GMUserFileSystem; 27 | 28 | @interface SpotlightFSController : NSObject { 29 | GMUserFileSystem* fs_; 30 | SpotlightFS* spotlightfs_; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Source/SpotlightFSController.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // SpotlightFSController.m 18 | // SpotlightFS 19 | // 20 | // Created by ted on 1/3/08. 21 | // 22 | 23 | #import "SpotlightFSController.h" 24 | #import 25 | 26 | @implementation SpotlightFSController 27 | 28 | - (void)didMount:(NSNotification *)notification { 29 | // Show the mount point in Finder window 30 | NSDictionary* userInfo = [notification userInfo]; 31 | NSString* mountPath = [userInfo objectForKey:kGMUserFileSystemMountPathKey]; 32 | NSString* parentPath = [mountPath stringByDeletingLastPathComponent]; 33 | [[NSWorkspace sharedWorkspace] selectFile:mountPath 34 | inFileViewerRootedAtPath:parentPath]; 35 | } 36 | 37 | - (void)didUnmount:(NSNotification*)notification { 38 | [[NSApplication sharedApplication] terminate:nil]; 39 | } 40 | 41 | - (void)applicationDidFinishLaunching:(NSNotification *)notification { 42 | NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 43 | [center addObserver:self selector:@selector(didMount:) 44 | name:kGMUserFileSystemDidMount object:nil]; 45 | [center addObserver:self selector:@selector(didUnmount:) 46 | name:kGMUserFileSystemDidUnmount object:nil]; 47 | 48 | NSString* mountPath = @"/Volumes/SpotlightFS"; 49 | spotlightfs_ = [[SpotlightFS alloc] init]; 50 | fs_ = [[GMUserFileSystem alloc] initWithDelegate:spotlightfs_ isThreadSafe:YES]; 51 | NSMutableArray* options = [NSMutableArray array]; 52 | NSString* volArg = 53 | [NSString stringWithFormat:@"volicon=%@", 54 | [[NSBundle mainBundle] pathForResource:@"SpotlightFSMount" ofType:@"icns"]]; 55 | [options addObject:volArg]; 56 | [options addObject:@"volname=SpotlightFS"]; 57 | [fs_ mountAtPath:mountPath withOptions:options]; 58 | } 59 | 60 | - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { 61 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 62 | [fs_ unmount]; // Just in case we need to unmount; 63 | [fs_ setDelegate:nil]; 64 | [spotlightfs_ release]; 65 | [fs_ release]; 66 | return NSTerminateNow; 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/Source/main.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2007 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // main.m 18 | // SpotlightFS 19 | // 20 | // Created by Greg Miller on 1/19/07. 21 | // 22 | 23 | #import 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | return NSApplicationMain(argc, (const char **) argv); 28 | } 29 | -------------------------------------------------------------------------------- /filesystems-objc/SpotlightFS/SpotlightFS_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SpotlightFS' target in the 'SpotlightFS' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /filesystems-objc/Support/NSError+POSIX.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+POSIX.h 3 | // 4 | // ================================================================ 5 | // Copyright (C) 2008 Google Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // ================================================================ 19 | // 20 | 21 | #import 22 | 23 | // Category on NSError to simplify creating an NSError based on posix errno. 24 | @interface NSError (POSIX) 25 | + (NSError *)errorWithPOSIXCode:(int)code; 26 | @end 27 | -------------------------------------------------------------------------------- /filesystems-objc/Support/NSError+POSIX.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+POSIX.m 3 | // 4 | // ================================================================ 5 | // Copyright (C) 2008 Google Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // ================================================================ 19 | // 20 | 21 | #import "NSError+POSIX.h" 22 | 23 | @implementation NSError (POSIX) 24 | + (NSError *)errorWithPOSIXCode:(int) code { 25 | return [NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:nil]; 26 | } 27 | @end 28 | 29 | -------------------------------------------------------------------------------- /filesystems-objc/Support/NSImage+IconData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | @class NSData; 20 | 21 | @interface NSImage (IconData) 22 | 23 | // Creates the data for a .icns file from this NSImage. You can use a width 24 | // of 128, 256 or 512 pixels (128 and 512 only supported on Leopard and later). 25 | - (NSData *)icnsDataWithWidth:(int)width; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /filesystems-objc/Support/YTVideo.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // YTVideo.h 18 | // YTFS 19 | // 20 | // Created by ted on 12/11/08. 21 | // 22 | #import 23 | 24 | // NOTE: This is a very simple class that can fetch an xml feed of videos from 25 | // YouTube and parse it into YTVideo objects. This is meant to be light 26 | // and simple for learning purposes; a real project should use the full-featured 27 | // GData Objective-C API: http://code.google.com/p/gdata-objectivec-client/ 28 | @interface YTVideo : NSObject { 29 | NSXMLNode* xmlNode_; 30 | NSXMLDocument* xmlDoc_; 31 | } 32 | 33 | // Returns a dictionary keyed by filename-safe video name of the top rated 34 | // videos on YouTube. The vales are YTVideo*. 35 | + (NSDictionary *)fetchTopRatedVideos; 36 | 37 | + (id)videoWithXMLNode:(NSXMLNode *)node; 38 | - (id)initWithXMLNode:(NSXMLNode *)node; 39 | 40 | // Returns the URL to the thumbnail image for the video. 41 | - (NSURL *)thumbnailURL; 42 | 43 | // Returns the URL that will play the video in a web browser. 44 | - (NSURL *)playerURL; 45 | 46 | // Returns NSData for the xml string for this video node in pretty-print format. 47 | - (NSData *)xmlData; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1 2 | *.mode1v3 3 | *.mode2v3 4 | *.perspective 5 | *.perspectivev3 6 | *.pbxuser 7 | 8 | build/ 9 | project.xcworkspace/ 10 | xcuserdata/ 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/YTFS/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /filesystems-objc/YTFS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | ${PRODUCT_NAME}.icns 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/README.txt: -------------------------------------------------------------------------------- 1 | YTFS 2 | 3 | YTFS is a a simple read-only file system that downloads a feed of top-rated 4 | YouTube videos and presents them in the root directory as a clickable webloc 5 | to the video. 6 | 7 | The DEVELOPER_OBJC_HOWTO is a step-by-step tutorial that walks you through 8 | creating the YTFS file system. Please read and follow the instructions in 9 | the tutorial located here: 10 | 11 | http://code.google.com/p/macfuse/wiki/DEVELOPER_OBJC_HOWTO 12 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/YTFS.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -s 2 | 3 | #pragma D option quiet 4 | 5 | macfuse_objc*:::delegate-entry 6 | /execname == "YTFS"/ 7 | { 8 | printf("%-14d %s: %s\n", timestamp, probefunc, copyinstr(arg0)); 9 | } 10 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/YTFS.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-objc/YTFS/YTFS.icns -------------------------------------------------------------------------------- /filesystems-objc/YTFS/YTFS_Controller.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // YTFS_Controller.h 18 | // YTFS 19 | // 20 | // Created by ted on 12/7/08. 21 | // 22 | #import 23 | 24 | @class GMUserFileSystem; 25 | @class YTFS_Controller; 26 | 27 | @interface YTFS_Controller : NSObject { 28 | GMUserFileSystem* fs_; 29 | YTFS_Controller* fs_delegate_; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/YTFS_Controller.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // YTFS_Controller.m 18 | // YTFS 19 | // 20 | // Created by ted on 12/7/08. 21 | // 22 | #import "YTFS_Controller.h" 23 | #import "YTFS_Filesystem.h" 24 | #import "YTVideo.h" 25 | #import 26 | 27 | @implementation YTFS_Controller 28 | 29 | - (void)mountFailed:(NSNotification *)notification { 30 | NSDictionary* userInfo = [notification userInfo]; 31 | NSError* error = [userInfo objectForKey:kGMUserFileSystemErrorKey]; 32 | NSLog(@"kGMUserFileSystem Error: %@, userInfo=%@", error, [error userInfo]); 33 | NSRunAlertPanel(@"Mount Failed", [error localizedDescription], nil, nil, nil); 34 | [[NSApplication sharedApplication] terminate:nil]; 35 | } 36 | 37 | - (void)didMount:(NSNotification *)notification { 38 | NSDictionary* userInfo = [notification userInfo]; 39 | NSString* mountPath = [userInfo objectForKey:kGMUserFileSystemMountPathKey]; 40 | NSString* parentPath = [mountPath stringByDeletingLastPathComponent]; 41 | [[NSWorkspace sharedWorkspace] selectFile:mountPath 42 | inFileViewerRootedAtPath:parentPath]; 43 | } 44 | 45 | - (void)didUnmount:(NSNotification*)notification { 46 | [[NSApplication sharedApplication] terminate:nil]; 47 | } 48 | 49 | - (void)applicationDidFinishLaunching:(NSNotification *)notification { 50 | // Pump up our url cache. 51 | NSURLCache* cache = [NSURLCache sharedURLCache]; 52 | [cache setDiskCapacity:(1024 * 1024 * 500)]; 53 | [cache setMemoryCapacity:(1024 * 1024 * 40)]; 54 | 55 | NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 56 | [center addObserver:self selector:@selector(mountFailed:) 57 | name:kGMUserFileSystemMountFailed object:nil]; 58 | [center addObserver:self selector:@selector(didMount:) 59 | name:kGMUserFileSystemDidMount object:nil]; 60 | [center addObserver:self selector:@selector(didUnmount:) 61 | name:kGMUserFileSystemDidUnmount object:nil]; 62 | 63 | NSString* mountPath = @"/Volumes/YTFS"; 64 | fs_delegate_ = 65 | [[YTFS_Filesystem alloc] initWithVideos:[YTVideo fetchTopRatedVideos]]; 66 | fs_ = [[GMUserFileSystem alloc] initWithDelegate:fs_delegate_ isThreadSafe:YES]; 67 | 68 | NSMutableArray* options = [NSMutableArray array]; 69 | NSString* volArg = 70 | [NSString stringWithFormat:@"volicon=%@", 71 | [[NSBundle mainBundle] pathForResource:@"YTFS" ofType:@"icns"]]; 72 | [options addObject:volArg]; 73 | [options addObject:@"volname=YTFS"]; 74 | [options addObject:@"rdonly"]; 75 | [fs_ mountAtPath:mountPath withOptions:options]; 76 | } 77 | 78 | - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { 79 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 80 | [fs_ unmount]; 81 | [fs_ release]; 82 | [fs_delegate_ release]; 83 | return NSTerminateNow; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/YTFS_Filesystem.h: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // YTFS_Filesystem.h 18 | // YTFS 19 | // 20 | // Created by ted on 12/7/08. 21 | // 22 | // Filesystem operations. 23 | // 24 | #import 25 | 26 | @class YTVideo; 27 | 28 | // The core set of file system operations. This class will serve as the delegate 29 | // for GMUserFileSystemFilesystem. For more details, see the section on 30 | // GMUserFileSystemOperations found in the documentation at: 31 | // http://macfuse.googlecode.com/svn/trunk/core/sdk-objc/Documentation/index.html 32 | @interface YTFS_Filesystem : NSObject { 33 | NSDictionary* videos_; 34 | } 35 | - (id)initWithVideos:(NSDictionary *)videos; 36 | - (YTVideo *)videoAtPath:(NSString *)path; 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/YTFS_Filesystem.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // YTFS_Filesystem.m 18 | // YTFS 19 | // 20 | // Created by ted on 12/7/08. 21 | // 22 | #import "YTFS_Filesystem.h" 23 | #import "YTVideo.h" 24 | #import "NSImage+IconData.h" 25 | #import 26 | 27 | // Category on NSError to simplify creating an NSError based on posix errno. 28 | @interface NSError (POSIX) 29 | + (NSError *)errorWithPOSIXCode:(int)code; 30 | @end 31 | @implementation NSError (POSIX) 32 | + (NSError *)errorWithPOSIXCode:(int) code { 33 | return [NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:nil]; 34 | } 35 | @end 36 | 37 | @implementation YTFS_Filesystem 38 | 39 | #pragma mark Directory Contents 40 | 41 | - (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error { 42 | if ([path isEqualToString:@"/"]) { 43 | return [videos_ allKeys]; 44 | } 45 | if ( error ) { 46 | *error = [NSError errorWithPOSIXCode:ENOENT]; 47 | } 48 | return nil; 49 | } 50 | 51 | #pragma mark Getting Attributes 52 | 53 | - (NSDictionary *)attributesOfItemAtPath:(NSString *)path 54 | userData:(id)userData 55 | error:(NSError **)error { 56 | if ([self videoAtPath:path]) { 57 | return [NSDictionary dictionary]; 58 | } 59 | return nil; 60 | } 61 | 62 | #pragma mark File Contents 63 | 64 | - (NSData *)contentsAtPath:(NSString *)path { 65 | YTVideo* video = [self videoAtPath:path]; 66 | if (video) { 67 | return [video xmlData]; 68 | } 69 | return nil; 70 | } 71 | 72 | #pragma mark FinderInfo and ResourceFork (Optional) 73 | 74 | - (NSDictionary *)finderAttributesAtPath:(NSString *)path 75 | error:(NSError **)error { 76 | NSDictionary* attribs = nil; 77 | if ([self videoAtPath:path]) { 78 | NSNumber* finderFlags = [NSNumber numberWithLong:kHasCustomIcon]; 79 | attribs = [NSDictionary dictionaryWithObject:finderFlags 80 | forKey:kGMUserFileSystemFinderFlagsKey]; 81 | } 82 | return attribs; 83 | } 84 | 85 | - (NSDictionary *)resourceAttributesAtPath:(NSString *)path 86 | error:(NSError **)error { 87 | NSMutableDictionary* attribs = nil; 88 | YTVideo* video = [self videoAtPath:path]; 89 | if (video) { 90 | attribs = [NSMutableDictionary dictionary]; 91 | NSURL* url = [video playerURL]; 92 | if (url) { 93 | [attribs setObject:url forKey:kGMUserFileSystemWeblocURLKey]; 94 | } 95 | url = [video thumbnailURL]; 96 | if (url) { 97 | NSImage* image = [[[NSImage alloc] initWithContentsOfURL:url] autorelease]; 98 | NSData* icnsData = [image icnsDataWithWidth:256]; 99 | [attribs setObject:icnsData forKey:kGMUserFileSystemCustomIconDataKey]; 100 | } 101 | } 102 | return attribs; 103 | } 104 | 105 | #pragma mark Init and Dealloc 106 | 107 | - (id)initWithVideos:(NSDictionary *)videos { 108 | if ((self = [super init])) { 109 | videos_ = [videos retain]; 110 | } 111 | return self; 112 | } 113 | - (void)dealloc { 114 | [videos_ release]; 115 | [super dealloc]; 116 | } 117 | 118 | - (YTVideo *)videoAtPath:(NSString *)path { 119 | NSArray* components = [path pathComponents]; 120 | if ([components count] != 2) { 121 | return nil; 122 | } 123 | YTVideo* video = [videos_ objectForKey:[components objectAtIndex:1]]; 124 | return video; 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/YTFS_Prefix.pch: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // Prefix header for all source files of the 'YTFS' target in the 'YTFS' project 18 | // 19 | 20 | #ifdef __OBJC__ 21 | #import 22 | #endif 23 | -------------------------------------------------------------------------------- /filesystems-objc/YTFS/main.m: -------------------------------------------------------------------------------- 1 | // ================================================================ 2 | // Copyright (C) 2008 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // ================================================================ 16 | // 17 | // main.m 18 | // YTFS 19 | // 20 | // Created by ted on 12/7/08. 21 | // 22 | #import 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | return NSApplicationMain(argc, (const char **) argv); 27 | } 28 | -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017, KF Interactive GmbH 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LoopbackFS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LoopbackFS.xcodeproj/project.xcworkspace/xcuserdata/trispo.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-swift/LoopbackFS/LoopbackFS.xcodeproj/project.xcworkspace/xcuserdata/trispo.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LoopbackFS/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // LoopbackFS 4 | // 5 | // Created by Gunnar Herzog on 27/01/2017. 6 | // Copyright © 2017 KF Interactive GmbH. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | @IBOutlet weak var window: NSWindow! 15 | 16 | private var notificationObservers: [NSObjectProtocol] = [] 17 | private var rootPath: String! 18 | private lazy var loopFileSystem: LoopbackFS = { 19 | return LoopbackFS(rootPath: self.rootPath) 20 | }() 21 | 22 | private lazy var userFileSystem: GMUserFileSystem = { 23 | return GMUserFileSystem(delegate: self.loopFileSystem, isThreadSafe: false) 24 | }() 25 | 26 | 27 | func applicationDidFinishLaunching(_ aNotification: Notification) { 28 | let panel = NSOpenPanel() 29 | panel.canChooseFiles = false 30 | panel.canChooseDirectories = true 31 | panel.allowsMultipleSelection = false 32 | panel.directoryURL = URL(fileURLWithPath: "/tmp") 33 | let returnValue = panel.runModal() 34 | 35 | guard returnValue != NSFileHandlingPanelCancelButton, let rootPath = panel.urls.first?.path else { exit(0) } 36 | 37 | addNotifications() 38 | 39 | self.rootPath = rootPath 40 | 41 | var options: [String] = ["native_xattr", "volname=LoopbackFS"] 42 | 43 | if let volumeIconPath = Bundle.main.path(forResource: "LoopbackFS", ofType: "icns") { 44 | options.insert("volicon=\(volumeIconPath)", at: 0) 45 | } 46 | 47 | // Do not use the 'native_xattr' mount-time option unless the underlying 48 | // file system supports native extended attributes. Typically, the user 49 | // would be mounting an HFS+ directory through LoopbackFS, so we do want 50 | // this option in that case. 51 | userFileSystem.mount(atPath: "/Volumes/loop", withOptions: options) 52 | } 53 | 54 | func addNotifications() { 55 | let mountObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name(kGMUserFileSystemDidMount), object: nil, queue: nil) { notification in 56 | print("Got didMount notification.") 57 | 58 | guard let userInfo = notification.userInfo, let mountPath = userInfo[kGMUserFileSystemMountPathKey] as? String else { return } 59 | 60 | let parentPath = (mountPath as NSString).deletingLastPathComponent 61 | NSWorkspace.shared().selectFile(mountPath, inFileViewerRootedAtPath: parentPath) 62 | } 63 | 64 | let failedObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name(kGMUserFileSystemMountFailed), object: nil, queue: .main) { notification in 65 | print("Got mountFailed notification.") 66 | 67 | guard let userInfo = notification.userInfo, let error = userInfo[kGMUserFileSystemErrorKey] as? NSError else { return } 68 | 69 | print("kGMUserFileSystem Error: \(error), userInfo=\(error.userInfo)") 70 | let alert = NSAlert() 71 | alert.messageText = "Mount Failed" 72 | alert.informativeText = error.localizedDescription 73 | alert.runModal() 74 | 75 | NSApplication.shared().terminate(nil) 76 | } 77 | 78 | let unmountObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name(kGMUserFileSystemDidUnmount), object: nil, queue: nil) { notification in 79 | print("Got didUnmount notification.") 80 | 81 | NSApplication.shared().terminate(nil) 82 | } 83 | 84 | self.notificationObservers = [mountObserver, failedObserver, unmountObserver] 85 | } 86 | 87 | func applicationShouldTerminate(_ sender: NSApplication) -> NSApplicationTerminateReply { 88 | notificationObservers.forEach { 89 | NotificationCenter.default.removeObserver($0) 90 | } 91 | notificationObservers.removeAll() 92 | 93 | userFileSystem.unmount() 94 | return .terminateNow 95 | } 96 | } 97 | 98 | -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LoopbackFS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LoopbackFS/Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Bridging-Header.h 3 | // LoopbackFS 4 | // 5 | // Created by Gunnar Herzog on 27/01/2017. 6 | // Copyright © 2017 KF Interactive GmbH. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LoopbackFS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2017 KF Interactive GmbH. All rights reserved. 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LoopbackFS/NSError+POSIX.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+POSIX.swift 3 | // LoopbackFS 4 | // 5 | // Created by Gunnar Herzog on 27/01/2017. 6 | // Copyright © 2017 KF Interactive GmbH. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension NSError { 12 | convenience init(posixErrorCode err: Int32) { 13 | self.init(domain: NSPOSIXErrorDomain, code: Int(err), userInfo: [NSLocalizedDescriptionKey: String(cString: strerror(err))]) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /filesystems-swift/LoopbackFS/LoopbackFS/Resources/LoopbackFS.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osxfuse/filesystems/7d2324e8c6af808087860182960bebebd16fc710/filesystems-swift/LoopbackFS/LoopbackFS/Resources/LoopbackFS.icns -------------------------------------------------------------------------------- /support/debugging/macfuse_u_fuse_fs.d: -------------------------------------------------------------------------------- 1 | #! /usr/sbin/dtrace -s 2 | 3 | #pragma D option quiet 4 | 5 | BEGIN 6 | { 7 | begints = timestamp; 8 | } 9 | 10 | pid$1:libfuse*dylib:fuse_fs_init:entry, 11 | pid$1:libfuse*dylib:fuse_fs_destroy:entry 12 | { 13 | self->begints = timestamp; 14 | self->init_destroy = 1; 15 | } 16 | 17 | pid$1:libfuse*dylib:fuse_fs_init:return, 18 | pid$1:libfuse*dylib:fuse_fs_destroy:return 19 | / self->init_destroy / 20 | { 21 | this->elapsed = timestamp - self->begints; 22 | 23 | printf("+%-12d %3d.%03d %-8d%-16s\n", (timestamp - begints) / 1000, 24 | this->elapsed / 1000000, (this->elapsed / 1000) % 1000, 25 | (int)arg1, probefunc + 8); 26 | 27 | self->begints = 0; 28 | self->init_destroy = 0; 29 | } 30 | 31 | pid$1:libfuse*dylib:fuse_fs*:entry 32 | / !self->init_destroy / 33 | { 34 | self->traceme = 1; 35 | self->pathptr = arg1; 36 | self->begints = timestamp; 37 | self->arg2 = arg2; 38 | } 39 | 40 | pid$1:libfuse*dylib:fuse_fs*:return 41 | / self->traceme && probefunc != "fuse_fs_getattr" / 42 | { 43 | this->elapsed = timestamp - self->begints; 44 | 45 | printf("+%-12d %3d.%03d %-8d%-16s%s\n", (timestamp - begints) / 1000, 46 | this->elapsed / 1000000, (this->elapsed / 1000) % 1000, 47 | (int)arg1, probefunc + 8, copyinstr(self->pathptr)); 48 | 49 | self->traceme = 0; 50 | self->pathptr = 0; 51 | self->begints = 0; 52 | } 53 | 54 | pid$1:libfuse*dylib:fuse_fs*:return 55 | / self->traceme && probefunc == "fuse_fs_getattr" / 56 | { 57 | this->elapsed = timestamp - self->begints; 58 | this->st = (struct stat *)copyin(self->arg2, sizeof(struct stat)); 59 | 60 | printf("+%-12d %3d.%03d %-8d%-16s%s (st_size=%lld)\n", (timestamp - begints) / 1000, 61 | this->elapsed / 1000000, (this->elapsed / 1000) % 1000, 62 | (int)arg1, probefunc + 8, copyinstr(self->pathptr), this->st->st_size); 63 | 64 | self->traceme = 0; 65 | self->pathptr = 0; 66 | self->begints = 0; 67 | } 68 | -------------------------------------------------------------------------------- /support/testing/posix_compat_test/Makefile: -------------------------------------------------------------------------------- 1 | CC_COMPILE = g++ -g -O0 2 | 3 | OBJECTS = \ 4 | posix_compat_test.o 5 | 6 | all: posix_compat_test 7 | 8 | posix_compat_test: $(OBJECTS) 9 | g++ -g -O0 -o $@ $(OBJECTS) 10 | 11 | clean: 12 | rm -f posix_compat_test *.o 13 | 14 | %.o :: %.cc 15 | $(CC_COMPILE) -c -o $@ $< 16 | --------------------------------------------------------------------------------