Files and Storage

RSS for tag

Ask questions about file systems and block storage.

Posts under Files and Storage tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Unable to read Internal APFS SSD drive
We are trying to read disk sectors raw Data. Sample code can be found at the bottom. For external drive, it is working fine. We are able to see raw data which is not zero. For internal ssd APFS drive, We only get data filled with zeroes. We have tried with System Integrity Protection enabling and disabling. Please let us know Why same API failing for internal APFS drive? Is there any specific API available for reading raw data of internal APFS drive? #include <fcntl.h> #include <unistd.h> #include <iomanip> int main() { // Adjust this to your disk device on macOS const char* diskPath = "/dev/rdisk1"; //internal SSD device on macOS // Size of a sector (usually 4096 bytes for most disks on macOS) const int sectorSize = 4096; // Number of sectors you want to read const int numSectors = 8; // Starting sector number off_t startSector = 0; // Open the disk device using low-level file I/O int diskFile = open(diskPath, O_RDONLY); if (diskFile == -1) { std::cerr << "Error opening disk file." << std::endl; return 1; } // Read multiple sectors into a buffer char buffer[numSectors * sectorSize]; ssize_t bytesRead = pread(diskFile, buffer, numSectors * sectorSize, startSector * sectorSize); // Close the disk file close(diskFile); if (bytesRead != numSectors * sectorSize) { std::cerr << "Error reading sectors." << std::endl; return 1; } // Display the contents of the sectors in hex for (int i = 0; i < numSectors * sectorSize; ++i) { std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)(unsigned char)buffer[i] << " "; if ((i + 1) % 16 == 0) { std::cout << std::endl; } } return 0; }
0
0
460
Feb ’24
About the key"Supports opening documents in place"and the Container Import of Xcode 15.2
when I use Xcode14 build on the iOS16, the keys"Supports opening documents in place"and"Application supports iTunes file sharing"works normally, it has a App folder in"My iPhone".But it's strange that when I update my Xcode and iOS to 15.2 and 17.2, it s don't working.not only there is not a App folder in"My iPhone",but also the container doesn't works too.More specifically speaking, I download the container from the device and add files into "Documents"folder. when I try to replace the container, it has no respond, and files cannot be founded in the device as well. But when I try to download the container from the device again, I found that the files is already there. Environment: MacBook Pro 2017 with macOS 13.6.3 Xcode 15.2 iPad Air 5 with iOS 17.2
1
0
512
Feb ’24
Clarification on Disk Space APIs - volumeAvailableCapacityForImportantUsageKey
Our application uses Disk Space API, specifically volumeAvailableCapacityForImportantUsageKey to determine the available free space on the device. However, we are facing challenges in understanding the reasoning criteria that an application needs to satisfy to use this API effectively. As part of our application requirement, we present an information modal to the user when disk space is low. Additionally, we log available disk space information and upload the logs to the cloud under certain conditions. We initially thought that E174.1 from the Privacy Manifest Files documentation fits our purpose. However, we are concerned about potentially violating the guideline: "Information accessed for this reason, or any derived information, may not be sent off-device." Could someone please provide additional clarity on how to navigate this fine line and ensure that our application aligns with the recommended practices and guidelines while handling disk space-related functionality? Thank you in advance for any insights or guidance you can provide! NOTE: We upload the logs to our server for troubleshooting and it may happen without user knowledge. Logs are encrypted and may contain the disk free space information
1
1
811
Feb ’24
NSFileProvider Extension crash on MacOS 14.4 Beta
NSFileProvider Extension based on Xamarin.Mac constantly crashes starting on MacOS 14.4 Beta Steps to Reproduce: Create simple Xamarin.Mac solution and add FileProviderExtension project Storage appears in Locations section in Finder Expected Behavior: Cloud storage shows folders content Actual Behavior: Cloud storage doesn't show folder content, just infinite running spinner FileProviderExtension process constantly crashes. It occurs only in OSX starting from 14.4 beta. Please review crash report and help me understand whats wrong and how to fix it. Simple project written with Swift and Xcode works without any issues. May be it’s related to issue described here https://forums.macrumors.com/threads/fileproviderctl-on-sonoma-14-4-here-we-f-ng-go-again.2418353. Thanks in advance! Environment-Info.log CrashReport.txt
9
0
775
Apr ’24
macOS load file progress indication
My app generates many files as large as 12 GB (limited by memory) and I use Picker() to select which to reload with FileManager(). The larger files can take three minutes to load (M2 Mini Pro) and it would be nice to have progress indication like Apple's App Store downloads with the mini spinner, file size and bytes loaded. From what I've read in "Developer Documentation", I must use a URLdelegate instance I have created, not the shared delegate, when effecting a URL download. "Downloading files in the Background" shows iOS code, not macOS, and it also uses a "shared" delegate. A post, here, dated years ago said what I seek is not possible and I have not found recent sample code to show otherwise. Can anyone shed light on this? Thanks
1
0
316
Feb ’24
External Disk Mount outside / volumes
Hi Everyone, We are facing distribution of external disk which is attached as /Volume/Untitled in the MAC machine. Ideally, this external disk shouldn't be part of the root. We're facing one issue when we add anything in the external disk, it first add in the root because this external disk is like an extension of the root one. That's why we're not able to get the benefit of the external disk, facing full storage crunch in all the machine. Can anyone please suggest a work around. Our requirement is we are looking to mount external disk as aseperate mount point (i.e /externaldisk instead of default /volumes/Untitled). Thank you
1
0
218
Feb ’24
Desktop dokuments are invisible but exist
So ever since I restarted my M1 Mac, I have encountered a peculiar issue where files on the desktop or in Finder are not visible, despite their existence being confirmed via Terminal and other applications like VS Code. This can be quite frustrating, especially when it disrupts workflow and access to crucial files. That problem could also happen after updating the Mac too. Resolve 1: You toggle the iCloud settings on and off by going to Settings > Profile > iCloud > iCloud drive > Desktop and Dokuments Folders. after that restart the Mac and it's fixed. this worked for the most people but it did not for me. Resolve 2: open the Terminal and Navigate the the Desktop Directory by typing in: cd ~/Desktop To enshure your in the directory you can see the ..desktop % behind the cursor, and after that, set the visibility to True, by typing in: chflags nohidden * This should fix the issue.
0
0
246
Feb ’24
how to read a file under project directory for both development and runtime?
For example I created a project aaa. aaa source folder is called aaa. that is aaa aaa/aaa then I put a data file in aaa/aaa/some.data now i want to test data in aaa/aaaTests/aaaTests.swift How can i access aaa/aaa/some.data in aaaTests.swift? If I want to access some.data inside aaa/aaa/ContentView.swift, how to write the code? I have been searching google and bing for days, but find no example answering my questions. Can anyone help me out? Thanks in advance.
1
0
553
Feb ’24
Loading JSON data to table view
Hi everyone, I am unable to load contents of my manually created JSON file to a table view. I am not sure what might be wrong with my code and that is why I am requesting for assistance. Here is the link to my GitHub repository: https://github.com/leonardsangoroh/AfricanCountriesInfo/tree/main Any form of help will be highly appreciated. Thank you in advance :)
1
0
276
Feb ’24
File (NSURL) programmatically downloaded from iCloud -> Could not open() the item: [1: Operation not permitted]
Hi there, i have an macOS app, sandboxed, compatibility 10.13 up to Sonoma, objective-C. I have a dropzone (or alternatively selection with NSOpenPanel) where users can drop files which results in an array of NSURLs. I create bookmarks to securely access them. This worked for years. Now i want to add iCloud support. Everything works good so far. I have methods to check the file status and download the file from icloud if NSURLUbiquitousItemDownloadingStatusKey == NSURLUbiquitousItemDownloadingStatusNotDownloaded Then i listen for the file, once the status key changes to NSURLUbiquitousItemDownloadingStatusCurrent i continue with processing the NSURL and i want to create bookmarkData: [filePathUrl bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:&amp;error]]; But this returns the error "Could not open() the item: [1: Operation not permitted]" So i was wondering if downloading the file from iCloud now changed the NSURL itself so the given permissions by dropping do not match the downloaded file? Adding [filePathUrl startAccessingSecurityScopedResource]; didn't change anything. Any help appreciated
0
0
326
Feb ’24
Advice for AppSupport to AppGroup migration before publishing
Hi all In pursuit of adopting widgets in my application, I have transitioned from AppSupport to AppGroup as storage location for Core Data. I have done a migration process/flow that goes as follows and which have been tested multiple times although I have yet to publish the update: Check if migration has taken place or not 1a. if yes continue to app 1b. If no continue flow Begin migration process 2a. Backup original store in AppSupport 2b. Migrate store to AppGroup 2c. Migrate userdefaults to AppGroup 2d. Update userdefaults with true for both hasMigratedToAppGroup and hasMigratedUserDefaultsToAppGroup Is there any tips or stuff to look for that hasn’t been taken in to account? How have you done it previously, and what would be recommended? Also, is there some specific tests to run/over many times get a baseline of how many is succeeding or failing? Thanks in advance.
4
0
559
Apr ’24
Options to keep config files or data files for a suite of apps
Hi, so I want to have a set of config files and data files which need to be accessible for say 3 of the apps I am building. And these files should be accessible to all 3 regardless of who makes them. The config file can have details like theme etc or sign in details etc. How do I go about doing this? Some of the things I thought of were, Using the app group storage folder, where if I understand correctly, if my apps belong to the same app group and have the required entitlement I can create files, they can be accessed by all 3 apps and they will exist until the last of the applications is uninstalled. Is this right? Letting the user pick a location/folder in "On my iPhone" in each of the apps and store the folder in bookmarks for each of the app. In this way the data will remain even after it is uninstalled. Is there any other way this can be done. Is there a recommended way of doing this?
1
0
363
Feb ’24
local doc save and iCloud data in same app
I have app that is using container for small settings data and iCloud for larger storage, but I also want to be able to save to local documents folder. When I do that the url that is created is not local docs, but: path: file:///var/mobile/Containers/Data/Application/85A8B8C9-C0C3-4843-A74C-5A951F593790/Documents/Dialog08:45,%2022%20Feb%202024 Here is code using to save to local docs folder. func saveDataToFile(data: String) { //file will be datetimedialog let formatter = DateFormatter() formatter.dateFormat = "HH:mm, d MMM y" var dateTime = Date.getCurrentDate() dateTime = formatter.string(from: Date.now) var saveFilename = "Dialog" saveFilename.append(dateTime) let path = getDocumentsDirectory().appendingPathComponent(saveFilename) print("path: \(path)") // let fileURL = URL(fileURLWithPath: data, relativeTo: path) do { try data.write(to: path, atomically: true, encoding: String.Encoding.utf8) } catch { print(error.localizedDescription) } } func getDocumentsDirectory() -> URL { let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) return paths[0] }
1
0
417
Feb ’24
Codeweaver Crossover problems, com.apple.provenance and SIP
Hi So Apple Support sent me here ... (Case: 102237195769 if anyone has access) My entire file system seems to be tagged with "com.apple.provenance" tags ... they're everywhere drwxr-xr-x@ 3 jon staff 96 20 Jan 2023 .vs-kubernetes com.apple.provenance 11 drwxr-xr-x@ 5 jon staff 160 21 Jun 2023 .vscode com.apple.provenance 11 drwxr-xr-x 12 jon staff 384 28 Feb 00:17 .vscode-server drwxr-xr-x@ 3 jon staff 96 11 Dec 2022 .warp com.apple.provenance 11 -rw-r--r--@ 1 jon staff 691 29 Nov 19:14 .wget-hsts com.apple.provenance 11 -rw-r--r--@ 1 jon staff 361 11 Dec 15:55 .zprofile com.apple.provenance 11 -rw-r--r--@ 1 jon staff 300 23 Jul 2023 .zprofile.bak com.apple.provenance 11 -rw-r--r--@ 1 jon staff 136 4 Dec 2022 .zprofile.pysave com.apple.provenance 11 -rw------- 1 jon staff 16802 27 Feb 22:20 .zsh_history drwx------@ 7 jon staff 224 21 Feb 14:28 .zsh_sessions com.apple.provenance 11 -rw-r--r--@ 1 jon staff 1681 24 Feb 18:24 .zshrc Now I don't know if this is related to the CrossOver (aka Wine) problem we're experiencing, or if it's a coincidence .. however I'd like to understand why every file that gets created ends up with this tag. When installing a Bottle in CO none of the shortcuts appear within the CO App .. which is where we started all of this. jon@ziggy ~ % cd Library/Application\ Support jon@ziggy Application Support % ls -lad@ CrossOver drwxr-xr-x 7 jon staff 224 28 Feb 02:02 CrossOver jon@ziggy Application Support % cd CrossOver jon@ziggy CrossOver % ls -la@ total 784 drwxr-xr-x 7 jon staff 224 28 Feb 02:02 . drwx------+ 184 jon staff 5888 28 Feb 08:56 .. drwxr-xr-x 3 jon staff 96 28 Feb 01:59 Bottles -rw-------@ 1 jon staff 239584 28 Feb 01:59 cxfixes.xml com.apple.provenance 11 -rw-------@ 1 jon staff 256 28 Feb 01:59 cxfixes.xml.sha256 com.apple.provenance 11 -rw-------@ 1 jon staff 155031 28 Feb 02:02 gstreamer-1.0-registry.x86_64.bin com.apple.provenance 11 drwxr-xr-x 5 jon staff 160 28 Feb 01:59 tie Problem Summary The Desktop shortcut keeps randomly vanishing from the Finder Favourites section Every file is tagged as com.apple.provenance and despite trying to clear the tags (which does work) they re-appear moments later. At this stage .. I've run out of ideas, Codeweavers support has gone silent and Apple Support said "try developer.apple.com" ... sigh Last night I flattened my M1 MBP and reinstalled. All looked good until Migration Assistant got involved and then it migrated across whatever is doing this as the problem persists.
0
0
454
Feb ’24
What does startaccessingsecurityscopedresource() mean for different OS?
So, I'm looking into startaccessingsecurityscopedresource() function and from my current understanding this is to get temporary access to files/folders you don't implicitly have access to i.e., that don't belong to your sandbox. I can understand what it means wrt macOS, iOS, iPadOS, but what does it mean in watchOS and tvOS where there isn't any file sharing between different apps? And what is it's relevance wrt using iCloud (if there is any?)
1
0
478
Mar ’24
Remove data when application is moved to bin - Swift multiplatform project
I want to store sensitive data, which has to be removed when the application is moved to bin, but not when the application is updated (install newer version of application). When I move application to bin the data still remain on the MacBook so when I install the application again, the sensitive data is loaded. This problem is only on macOS, because iOS and iPadOS clear all data when I uninstall them. I tried many options of storing. SQLite file stored in applicationSupportDirectory, temporaryDirectory, but nothing worked. I also tried to store this data using UserDefaults, but also unsuccessful. I expect that I install application and it will store this data somewhere, when I update the application, the data remain, but when I uninstall this application by moving it to BIN, it will remove this data.
1
0
324
Mar ’24