Hello,
I'm currently working on a filesystem using the objc sdk (to learn/get
comfortable with objc).
I've noticed that some "features" of a filesystem are not available
via the objc sdk.
That's why I've build a small patch to fix that. (patched against
2.1.9, but works also great on the git repo)
The defines are made so that a filesystem can "see" if those additions
are supported, and skip if they don't. I'm unsure whether this is the
best way or if there is another one.
Anyway it's great that macfuse now goes ahead (new repo and so on).
I think the "TODO: NSFileSystemNumber? Or does fuse do that for us?"
note can be deleted, because you can either specify the inode and the
option "use_ino" (which I do now) or don't and fuse will create those
for you.
ALeX.
###
diff -ru macfuse-rebel-2.1.9/core/sdk-objc/GMUserFileSystem.h macfuse-
rebel-2.1.9-impr_sdk-objc/core/sdk-objc/GMUserFileSystem.h
--- macfuse-rebel-2.1.9/core/sdk-objc/GMUserFileSystem.h 2010-11-13
15:58:47.000000000 +0100
+++ macfuse-rebel-2.1.9-impr_sdk-objc/core/sdk-objc/GMUserFileSystem.h
2011-05-04 23:34:39.000000000 +0200
@@ -682,6 +682,13 @@
*/
extern NSString* const kGMUserFileSystemFileBackupDateKey;
+/*!
+ * @abstract For file size in 512 byte blocks.
+ * @discussion The value should be an NSNumber that is the size in
512 byte blocks.
+ */
+extern NSString* const kGMUserFileSystemFileSizeInBlocksKey;
+#define kGMUserFileSystemFileSizeInBlocksKeyExists
+
#pragma mark Additional Volume Attribute Keys
/*! @group Additional Volume Attribute Keys */
@@ -693,6 +700,22 @@
*/
extern NSString* const
kGMUserFileSystemVolumeSupportsExtendedDatesKey;
+/*!
+ * @abstract Specifies the maximum filename length.
+ * @discussion The value should be a integer NSNumber with the
+ * maximum filename length, is omitted 255 is assumed.
+ */
+extern NSString* const kGMUserFileSystemVolumeMaxFilenameLengthKey;
+#define kGMUserFileSystemVolumeMaxFilenameLengthKeyExists
+
+/*!
+ * @abstract Specifies the File system block size.
+ * @discussion The value should be a integer NSNumber with the
+ * file system block size, if omitted 4096 is assumed.
+ */
+extern NSString* const kGMUserFileSystemVolumeFileSystemBlockSizeKey;
+#define kGMUserFileSystemVolumeFileSystemBlockSizeKeyExists
+
#pragma mark Additional Finder and Resource Fork keys
/*! @group Additional Finder and Resource Fork Keys */
diff -ru macfuse-rebel-2.1.9/core/sdk-objc/GMUserFileSystem.m macfuse-
rebel-2.1.9-impr_sdk-objc/core/sdk-objc/GMUserFileSystem.m
--- macfuse-rebel-2.1.9/core/sdk-objc/GMUserFileSystem.m 2010-11-13
15:58:47.000000000 +0100
+++ macfuse-rebel-2.1.9-impr_sdk-objc/core/sdk-objc/GMUserFileSystem.m
2011-05-04 23:33:31.000000000 +0200
@@ -79,7 +79,10 @@
GM_EXPORT NSString* const kGMUserFileSystemFileAccessDateKey =
@"kGMUserFileSystemFileAccessDateKey";
GM_EXPORT NSString* const kGMUserFileSystemFileChangeDateKey =
@"kGMUserFileSystemFileChangeDateKey";
GM_EXPORT NSString* const kGMUserFileSystemFileBackupDateKey =
@"kGMUserFileSystemFileBackupDateKey";
+GM_EXPORT NSString* const kGMUserFileSystemFileSizeInBlocksKey =
@"kGMUserFileSystemFileSizeInBlocksKey";
GM_EXPORT NSString* const
kGMUserFileSystemVolumeSupportsExtendedDatesKey =
@"kGMUserFileSystemVolumeSupportsExtendedDatesKey";
+GM_EXPORT NSString* const kGMUserFileSystemVolumeMaxFilenameLengthKey
= @"kGMUserFileSystemVolumeMaxFilenameLengthKey";
+GM_EXPORT NSString* const
kGMUserFileSystemVolumeFileSystemBlockSizeKey =
@"kGMUserFileSystemVolumeFileSystemBlockSizeKey";
// TODO: Remove comment on EXPORT if/when setvolname is supported.
/* GM_EXPORT */ NSString* const
kGMUserFileSystemVolumeSupportsSetVolumeNameKey =
@"kGMUserFileSystemVolumeSupportsSetVolumeNameKey";
@@ -701,12 +704,14 @@
}
// Maximum length of filenames
- // TODO: Create our own key so that a fileSystem can override this.
- stbuf->f_namemax = 255;
+ NSNumber* namemax = [attributes
objectForKey:kGMUserFileSystemVolumeMaxFilenameLengthKey];
+ assert(namemax);
+ stbuf->f_namemax = (unsigned long) [namemax longLongValue];
// Block size
- // TODO: Create our own key so that a fileSystem can override this.
- stbuf->f_bsize = stbuf->f_frsize = 4096;
+ NSNumber* blocksize = [attributes
objectForKey:kGMUserFileSystemVolumeFileSystemBlockSizeKey];
+ assert(blocksize);
+ stbuf->f_bsize = stbuf->f_frsize = (unsigned long) [blocksize
longLongValue];
// Size in blocks
NSNumber* size = [attributes objectForKey:NSFileSystemSize];
@@ -837,20 +842,22 @@
#endif
// Size for regular files.
- // TODO: Revisit size for directories.
- if (![fileType isEqualToString:NSFileTypeDirectory]) {
- NSNumber* size = [attributes objectForKey:NSFileSize];
- if (size) {
- stbuf->st_size = [size longLongValue];
- }
+ NSNumber* size = [attributes objectForKey:NSFileSize];
+ if (size) {
+ stbuf->st_size = [size longLongValue];
}
// Set the number of blocks used so that Finder will display size
on disk
// properly. The man page says that this is in terms of 512 byte
blocks.
- if (stbuf->st_size > 0) {
- stbuf->st_blocks = stbuf->st_size / 512;
- if (stbuf->st_size % 512) {
- ++(stbuf->st_blocks);
+ NSNumber* blocks = [attributes
objectForKey:kGMUserFileSystemFileSizeInBlocksKey];
+ if (blocks) {
+ stbuf->st_blocks = [blocks longLongValue];
+ }else{
+ if (stbuf->st_size > 0) {
+ stbuf->st_blocks = stbuf->st_size / 512;
+ if (stbuf->st_size % 512) {
+ ++(stbuf->st_blocks);
+ }
}
}
@@ -1405,6 +1412,8 @@
[attributes setObject:defaultSize forKey:NSFileSystemFreeSize];
[attributes setObject:defaultSize forKey:NSFileSystemNodes];
[attributes setObject:defaultSize forKey:NSFileSystemFreeNodes];
+ [attributes setObject:[NSNumber numberWithInt:255]
forKey:kGMUserFileSystemVolumeMaxFilenameLengthKey];
+ [attributes setObject:[NSNumber numberWithInt:4096]
forKey:kGMUserFileSystemVolumeFileSystemBlockSizeKey];
// TODO: NSFileSystemNumber? Or does fuse do that for us?
// The delegate can override any of the above defaults by
implementing the
--
You received this message because you are subscribed to the Google Groups
"MacFUSE" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/macfuse?hl=en.