Re: Updated APFS guide

2017-03-31 Thread Thomas Tempelmann
On Sat, Apr 1, 2017 at 1:32 AM, Brendan Shanks  wrote:

> The Apple File System Guide was updated yesterday with additional info
> about filenames, iOS 10.3, and macOS 10.12.4. Quick summary: no
> normalization, iOS 10.3 is case-sensitive, 10.12.4 now has (beta)
> case-insensitive AFPS.
>
> https://developer.apple.com/library/content/documentation/Fi
> leManagement/Conceptual/APFS_Guide/FAQ/FAQ.html
>
>
Thanks for the pointer.

I have trouble understanding this line:

The case-insensitive variant of APFS is normalization-preserving, but not
> normalization-sensitive."


I assume this is the mode that we now have in iOS 10.3.

I ask myself: What is meant by "sensitive" here? I know about
case-sensitivity. There, on a *non-case-sensitive* HFS system, I can pass
names in any case and they'll all be matched up with the same file name
stored on-disk. Right?

So, analogously, to my understanding, if I use AFPS on iOS, which is *non-*
*normalization-sensitive*, wouldn't it mean that I can pass differently
normalized (e.g. composited and decomposited) names to the FS API, and they
would all match the same file name on disk?

However, that contradicts this part from the same article, doesn't it:

For example, attempting to create a file using one normalization behavior
> and opening that file using another normalization behavior may result in
> ENOENT


Could someone tell me where my error in this logic is?

Thomas
 ___
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list  (Filesystem-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/filesystem-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Updated APFS guide

2017-03-31 Thread Brendan Shanks
The Apple File System Guide was updated yesterday with additional info about 
filenames, iOS 10.3, and macOS 10.12.4. Quick summary: no normalization, iOS 
10.3 is case-sensitive, 10.12.4 now has (beta) case-insensitive AFPS.

https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html

Brendan
 ___
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list  (Filesystem-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/filesystem-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSURL getResourceValue: for NSURLVolumeMaximumFileSizeKey returns nil

2017-03-31 Thread Jim Luther
As -[NSURL getResourceValue:forKey:error:] is documented, "If this method 
returns YES and the value is populated with nil, it means that the resource 
property is not available for the specified resource, and that no errors 
occurred when determining that the resource property was unavailable." So YES 
and nil is a valid response.

The NSURLVolumeMaximumFileSizeKey property value comes from two sources: 
pathconf() with _PC_FILESIZEBITS, or from getattrlist() from the 
ATTR_VOL_CAPABILITIES attribute and the VOL_CAP_FMT_2TB_FILESIZE capability.

Here's code (not the real code but the exact same algorithm) that shows how the 
value is calculated:

int getMaxFileSize(const char *path, int64_t *maxFileSize)
{
int result;
struct statfs statfsBuf;

// get the file system's mount point path for the input path
result = statfs(path, );
if ( result == 0 ) {
long fileSizeBits = pathconf(statfsBuf.f_mntonname, _PC_FILESIZEBITS);
if (fileSizeBits == -1) {
// if _PC_FILESIZEBITS isn't supported, check for 
VOL_CAP_FMT_2TB_FILESIZE
bool fileSystemSupports2TBFileSize = false;

// get the supported capabilities
struct attrlist attrList;
struct volCapabilitiesBuf {
u_int32_t length;
vol_capabilities_attr_t capabilities;
} __attribute__((aligned(4), packed));
struct volCapabilitiesBuf volCaps;

memset(, 0, sizeof(attrList));
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES;
result = getattrlist(statfsBuf.f_mntonname, , , 
sizeof(volCaps), 0);
if ( result == 0 ) {
fileSystemSupports2TBFileSize = 
((volCaps.capabilities.capabilities[VOL_CAPABILITIES_FORMAT] & 
VOL_CAP_FMT_2TB_FILESIZE) && 
(volCaps.capabilities.valid[VOL_CAPABILITIES_FORMAT] & 
VOL_CAP_FMT_2TB_FILESIZE));
}

if ( fileSystemSupports2TBFileSize ) {
// use Supports2TBFileSize
*maxFileSize = LONG_LONG_MAX;
}
else {
// otherwise, we don't know
*maxFileSize = -1LL;
}
}
else if ( fileSizeBits > 64 ) {
// off_t is signed long long, so it cannot be more than 
LONG_LONG_MAX
*maxFileSize = LONG_LONG_MAX;
}
else if ( fileSizeBits < 32 ) {
// POSIX spec says 'Minimum Acceptable Value: 32' for FILESIZEBITS
*maxFileSize = INT_MAX;
}
else {
// 32...64 bits: shift off the bits we don't need
*maxFileSize = (int64_t)((u_int64_t)0xLL >> 
(u_int64_t)(65 - fileSizeBits));
}
}
return result;
}

if NSURLVolumeMaximumFileSizeKey is returning nil with no errors, maxFileSize 
is -1LL, and the only way maxFileSize will be -1LL is if pathconf() returned an 
error, and the file system is saying VOL_CAP_FMT_2TB_FILESIZE is not valid and 
set (capabilities).

Hope that helps™

- Jim

> On Mar 31, 2017, at 2:33 PM, Scott Talbert  wrote:
> 
> Hello,
> 
> Can anyone tell me why calling NSURL -getResourceValue:forKey:error: with key 
> NSURLVolumeMaximumFileSizeKey would return a nil resource value for a given 
> volume?  The function returns YES and error is nil also.
> 
> I can see from running dtruss that it in turn calls getattrlist().  If I call 
> getattrlist() myself on the same volume, I can see the bits I would think it 
> is looking at are set correctly - VOL_CAP_FMT_2TB_FILESIZE.
> 
> Thanks,
> Scott
> ___
> Do not post admin requests to the list. They will be ignored.
> Filesystem-dev mailing list  (Filesystem-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/filesystem-dev/luther.j%40apple.com
> 
> This email sent to luthe...@apple.com

 ___
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list  (Filesystem-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/filesystem-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com