Apple File System is the default file system for iOS 10.3 and later, and for macOS High Sierra and later.

Posts under APFS tag

34 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Disk Utility / diskutil Partition Freezes
Hello Apple Developer Community, I'm encountering a persistent issue while attempting to create a new partition on my Mac, and I'm hoping to get some assistance or insights from anyone who might have faced a similar problem. Issue Description: I'm trying to partition my internal drive. I initially used Disk Utility.app for this purpose. The partitioning process starts, but consistently freezes when it reaches approximately 10-20% completion. I've left it running overnight (for over 9 hours), but there was no progress, and the application remained unresponsive at that percentage. After several attempts with Disk Utility, I decided to try using the diskutil commands in Terminal to see if that would yield a different result. I used commands such as diskutil apfs resizeContainer and diskutil partitionDisk. Unfortunately, these commands also result in the same behavior: the process starts, reports progress up to about 10-20%, and then completely freezes without any further output or completion, requiring me to force-quit Terminal. Mac Model: Apple M4 Pro MacOS Version: Sequoia 15.6
0
0
25
20h
Constructing a filesystem sandbox, how to disable file events
I'm working on a build system similar to Bazel where each build action runs in a sandbox. The sandbox contains only the files that the user defined as input to ensure that the build action doesn't have any implicit dependencies. Bazel achieves this by creating a "symlink forest" to the original source files. This works, but I have observed fseventsd using significant CPU during a Bazel build, presumably because of all the symlinks that get created. Is there a way to disable file events for a directory or a volume? The "File System Events Programming Guide" in the Documentation Archive mentions placing an empty file named no_log in the .fseventsd directory at the root of the volume, but when testing on macOS 15.5 with APFS that appears to no longer work. Related, is a "symlink forest" the best way to create a sandbox like this? Or is there a different method one can use to provide a view of a subset of the files in a directory tree? I read up on the App Sandbox but that seems too coarse grained. Something like Linux's overlayfs would work well, and maybe one can achieve a similar functionality with firmlinks? Curious about folks thoughts here. Thanks in advance!
1
0
106
3w
Why is using clonefile for a folder strongly discouraged?
As a part of the video editing app I’m working on, I want to efficiently copy a folder of resources on the same (local) filesystem. Because iOS is on APFS, cloning (CoW) is an option. I read the documentation for clonefile(2) which states that cloning a folder works but is strongly discouraged. I did a small sample project which demonstrates that using clonefile on a folder works correctly and is 10× faster than using FileManager’s copyItem method. My questions: The main one I’m interested in: Why is using clonefile for a folder strongly discouraged? Is FileManager using cloning behind the scenes? Or more exactly how guaranteed are we it will use it? (I know it does, I tried manually cping the resources and it was thousands of times slower.)
2
0
90
May ’25
Terminal Command to get the same file count as Get Info in finder
Hi All, I am looking for a terminal command to get the exact same output as the file count you recieve when using Get Info in finder. The closest i can get is using the find command with flags: find 'path/to/folder' -not -path '*/\.*' -and -not -path '*\.key/*' -and -not -path '*\.numbers/*' -and -not -path '*\.pages/*' -and -not -path '*__MACOSX/*' -and -not -path '*\.pdf/*' -and -not -path '*\.app/*' -and -not -path '*\.rtfd/*' | wc -l I will be searching on an external volume that sometimes produces keynote save files that finder sometimes sees as a package and sometimes sees as a folder. If a folder finder counts the items contained if a package it doesn't, I need the command or script to mimic this behaviour. In the example of the screenshot get info on the top folder produces a count of 14 and the find command produces a count of 23. There are also other behaviours that differ the file count between them but i'm not sure what causes them. Any help on a solution it being a command or script would be much apreciated. Thanks, James
1
0
75
May ’25
public API which allows to get information about APFS
Hello, I am working on a daemon which collects information about disk space usage on macOS. APFS has quite complex structure and there is a challenge to get detailed info. My application must provide disk usage by APFS containers. Are there any recommended way to get space usage by particular APFS volume? Are there any recommended way to get free space on particular APFS container? Are there any recommended way to enumerate APFS containers and volumes? I am using Disk Arbitration to get APFS info. However, I get restricted info about space usage because I get get disk usage for mounted volumes only. Are there any public API (daemon-safe) which allows to easily get disk space usage on macOS? Thank you in advance, Pavel
6
0
94
May ’25
get space which is used on an APFS volume
Hello, I am trying to get space which is consumed by APFS volume. The call getattrlist() works fine on macOS 15 (Apple silicon). However, it returns EINVAL on macOS 11.7.10 (Intel) if ATTR_VOL_SPACEUSED is defined. struct VolAttrBuf { u_int32_t length; off_t spaceUsed; } __attribute__((aligned(4), packed)); int64_t GetVolumeSpaceUsed(const std::string& mountPath) { struct attrlist attrList; std::memset(&attrList, 0, sizeof(attrList)); attrList.bitmapcount = ATTR_BIT_MAP_COUNT; attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_SPACEUSED; VolAttrBuf attrBuf; if (getattrlist(mountPath.c_str(), &attrList, &attrBuf, sizeof(attrBuf), 0) || attrBuf.length > sizeof(attrBuf)) { std::cout << "getattrlist() failed with errno (" << errno << ")" << std::endl; return -1; } return attrBuf.spaceUsed; } Is it bug or ATTR_VOL_SPACEUSED is unsupported on macOS 11? Are there any other way to get space which is used on an APFS volume? (C++) Thank you in advance, Pavel
2
0
57
May ’25
FileAttributeKey.protectionKey's value is always nil in Simulator
It seems like this is not supported in the Simulator because when I run my Unit tests and I try to read protection key-value the value is always nil, even if I set the data protection level when I write the file. On device this key returns the expected value. Is it possible to have the simulator support the data protection classes to run my unit tests? FYI Im testing on iOS
2
0
54
Apr ’25
When getting the PHPickerResult from user selecting media in the Photos app, how to check file extension?
when I get results from picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) and I load the image using itemProvider .loadFileRepresentation (the itemProvider is the NSItemProvider provided by the PHPickerResult) will the url that's returned by this method be guaranteed to have the file extension ie, "file://image.jpeg" not "file://image" I want to know if i need to just check the extension to know its file type. (FYI in case this makes a difference, im only interested in user screenshots and screenrecordings)
7
0
64
Apr ’25
error 49244 when using asr
a few times, for reasons unknown to me, asr restore processes broke with error 49244. Basically, the process get interrupted, most cases when is about to finish, with just a laconic message saying "Volume replication failed - error 49244". Where can I get information on this error, what exactly means, what causes it and more important, how to troubleshoot it. Any help will be appreciated, Thanks!!
0
0
278
Feb ’25
diskutil "eraseDisk" on disk0 using terminal
Hi Apple Team & Everyone, Can someone guide me why sending 'diskutil eraseDisk APFS "WIPED" GPT /dev/disk0' command via terminal to remove/wipe the main physical drive (disk0) is failed? I tried booting into recovery mode, but it still didn’t work. The command returned the following error: Started erase on disk0 Unmounting disk The volume on disk0 couldn't be unmounted because it is in use by process 0 (kernel). Error: -69877: Couldn't open device I understand that we can use Disk Utility (GUI) to unmount and erase the drive. Is it possible to perform this operation via Terminal to erase disk0? I would appreciate any guidance on this. Regards, Winson
2
0
664
Feb ’25
Equivalent macOS API for GetFileInformationByHandle to Retrieve File Attributes (e.g., Sync Drive Attributes)
I'm working on a cross-platform application that needs to access file attributes, specifically for files and directories in sync drives like OneDrive. On Windows, I use the GetFileInformationByHandle API to retrieve attributes such as FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS and FILE_ATTRIBUTE_RECALL_ON_OPEN to identify files that are stored remotely or in the cloud. Is there an equivalent API or mechanism on macOS to achieve the same? Specifically, I’m looking for a way to: Identify attributes similar to cloud/offline storage status for files in synced drives (e.g., OneDrive, DropBox etc). Retrieve metadata to distinguish files/folders stored locally versus those stored remotely and downloaded on access. If there’s a preferred macOS framework (like Core Services or FileManager in Swift) for such operations, examples would be greatly appreciated!
1
0
368
Jan ’25
Detection of Sync Drives such as OneDrive, DropBox etc.
I'm working on a cross-platform application that needs to access file attributes, specifically for files and directories in sync drives like OneDrive. On Windows, I use the GetFileInformationByHandle API to retrieve attributes such as FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS and FILE_ATTRIBUTE_RECALL_ON_OPEN to identify files that are stored remotely or in the cloud. Is there an equivalent API or mechanism on macOS to achieve the same? Specifically, I’m looking for a way to: Identify attributes similar to cloud/offline storage status for files in synced drives (e.g., OneDrive, iCloud Drive). Retrieve metadata to distinguish files/folders stored locally versus those stored remotely and downloaded on access. If there’s a preferred macOS framework (like Core Services or FileManager in Swift) for such operations, examples would be greatly appreciated!
1
0
279
Jan ’25
Mac App Crashing
Hi, I have a problem with my Mac crashing sims 4. can you let me know if this is a Mac problem or a sims 4 problem ? Link to Mac Info : https://prnt.sc/NYG0jn8_u0dB Link to crash report : https://prnt.sc/UImzDIsqdVYn
1
0
322
Jan ’25
App review returned rejected
Hello, I have a problem with the fact that my application requires a login, I provided it to Apple, and after testing it in Test Flight everything worked fine for me, nice, when I gave it to Apple for review and release, they returned the application to me saying that I can't log in, they don't know where it is problem?
1
0
358
Dec ’24