|
| 1 | +# P0.5 isolated metadata probe source |
| 2 | + |
| 3 | +Evidence attachment for [the P0.5 report](2026-10-14-batch-rename-p05.md), not a product classifier or registered QA application. |
| 4 | + |
| 5 | +The following source is the exact one-shot Objective-C CLI used on 2026-10-14. |
| 6 | +SHA-256 of the extracted UTF-8 source, including its final newline: |
| 7 | +`8747fa4021a439acf18ecb78fefbd5dcc1a4a09c07cc0d44d6cbcce30d10d414`. |
| 8 | + |
| 9 | +Only execute against newly created isolated fixtures. The caller creates an empty |
| 10 | +`ordinary-file`, an empty `ordinary-directory`, and `symlink-control` pointing to |
| 11 | +`ordinary-file`; `missing-control` must not exist. The observed run used an owned |
| 12 | +0700 directory under `/private/tmp`. No cloud, NAS or user-content input was used. |
| 13 | + |
| 14 | +Compile the extracted source as `probe.m` with: |
| 15 | + |
| 16 | +```sh |
| 17 | +xcrun clang -fobjc-arc -fblocks -Wall -Wextra -Werror -mmacosx-version-min=13.0 -framework Foundation -framework FileProvider probe.m -o probe |
| 18 | +./probe /absolute/path/to/owned-fixture-directory |
| 19 | +``` |
| 20 | + |
| 21 | +The deployment flag is not macOS 13 runtime evidence. This CLI has no App Sandbox |
| 22 | +entitlement or File Provider identity; the first recorded run used Codex's command |
| 23 | +sandbox and the second a command-scoped approved host execution. Neither is a |
| 24 | +signed FileMint sandbox test. Materialization policy is changed only for this |
| 25 | +process and restored at exit. No global policy or TCC state is changed. |
| 26 | + |
| 27 | +`app_sandbox_entitlement`, `metadata_only` and `unmanaged_classification` are |
| 28 | +source labels, not runtime detections or classifier assertions. The other JSON |
| 29 | +values are API observations. `identity_and_size_unchanged` compares only device, |
| 30 | +inode, size and flags. Five-second callback deadlines do not bound synchronous |
| 31 | +Foundation/kernel calls; the observed local calls completed, but managed-input |
| 32 | +responsiveness and side effects remain untested. |
| 33 | + |
| 34 | +```objective-c |
| 35 | +#import <Foundation/Foundation.h> |
| 36 | +#import <FileProvider/FileProvider.h> |
| 37 | +#include <sys/stat.h> |
| 38 | +#include <sys/mount.h> |
| 39 | +#include <sys/attr.h> |
| 40 | +#include <sys/resource.h> |
| 41 | +#include <errno.h> |
| 42 | + |
| 43 | +static NSDictionary *ErrorCode(NSError *error) { |
| 44 | + return error ? @{ @"domain": error.domain, @"code": @(error.code) } : @{}; |
| 45 | +} |
| 46 | + |
| 47 | +static NSDictionary *Await(void (^start)(void (^)(NSDictionary *))) { |
| 48 | + NSLock *lock = [NSLock new]; |
| 49 | + __block NSDictionary *result = nil; |
| 50 | + start(^(NSDictionary *value) { |
| 51 | + [lock lock]; result = [value copy]; [lock unlock]; |
| 52 | + }); |
| 53 | + NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:5]; |
| 54 | + while ([deadline timeIntervalSinceNow] > 0) { |
| 55 | + [lock lock]; NSDictionary *snapshot = result; [lock unlock]; |
| 56 | + if (snapshot) return snapshot; |
| 57 | + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode |
| 58 | + beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.02]]; |
| 59 | + } |
| 60 | + return @{ @"status": @"timeout" }; |
| 61 | +} |
| 62 | + |
| 63 | +static NSDictionary *Probe(NSURL *url, NSString *label) { |
| 64 | + NSMutableDictionary *row = [@{ @"fixture": label } mutableCopy]; |
| 65 | + struct stat before = {0}; |
| 66 | + int rc = lstat(url.fileSystemRepresentation, &before); |
| 67 | + row[@"lstat"] = rc ? @{ @"errno": @(errno) } : @{ |
| 68 | + @"mode_type": @(before.st_mode & S_IFMT), @"dataless": @((before.st_flags & SF_DATALESS) != 0), |
| 69 | + @"flags": @(before.st_flags), @"size": @(before.st_size) |
| 70 | + }; |
| 71 | + if (rc || !(S_ISREG(before.st_mode) || S_ISDIR(before.st_mode))) { |
| 72 | + row[@"eligibility"] = @"rejected-before-provider-query"; |
| 73 | + return row; |
| 74 | + } |
| 75 | + NSArray<NSURLResourceKey> *keys = @[ |
| 76 | + NSURLIsRegularFileKey, NSURLIsDirectoryKey, NSURLIsSymbolicLinkKey, |
| 77 | + NSURLIsAliasFileKey, NSURLIsPackageKey, NSURLIsWritableKey, |
| 78 | + NSURLIsUbiquitousItemKey, NSURLUbiquitousItemDownloadingStatusKey, |
| 79 | + NSURLUbiquitousItemIsExcludedFromSyncKey, |
| 80 | + NSURLVolumeIsLocalKey, NSURLVolumeIsReadOnlyKey, |
| 81 | + NSURLVolumeSupportsCaseSensitiveNamesKey, NSURLVolumeSupportsExclusiveRenamingKey, |
| 82 | + NSURLVolumeSupportsPersistentIDsKey |
| 83 | + ]; |
| 84 | + NSMutableDictionary *resources = [NSMutableDictionary new]; |
| 85 | + for (NSURLResourceKey key in keys) { |
| 86 | + id value = nil; NSError *error = nil; |
| 87 | + BOOL ok = [url getResourceValue:&value forKey:key error:&error]; |
| 88 | + resources[key] = @{ @"ok": @(ok), @"value": value ?: [NSNull null], @"error": ErrorCode(error) }; |
| 89 | + } |
| 90 | + row[@"resources"] = resources; |
| 91 | + struct statfs fs = {0}; |
| 92 | + rc = statfs(url.fileSystemRepresentation, &fs); |
| 93 | + row[@"statfs"] = rc ? @{ @"errno": @(errno) } : @{ |
| 94 | + @"type": @(fs.f_fstypename), @"local": @((fs.f_flags & MNT_LOCAL) != 0), |
| 95 | + @"readonly": @((fs.f_flags & MNT_RDONLY) != 0) |
| 96 | + }; |
| 97 | + struct attrlist attrs = {0}; |
| 98 | + attrs.bitmapcount = ATTR_BIT_MAP_COUNT; |
| 99 | + attrs.commonattr = ATTR_CMN_RETURNED_ATTRS; |
| 100 | + attrs.forkattr = ATTR_CMNEXT_EXT_FLAGS; |
| 101 | + struct { uint32_t length; attribute_set_t returned; uint64_t flags; } output = {0}; |
| 102 | + rc = getattrlist(url.fileSystemRepresentation, &attrs, &output, sizeof(output), |
| 103 | + FSOPT_NOFOLLOW | FSOPT_ATTR_CMN_EXTENDED); |
| 104 | + BOOL valid = !rc && output.length >= sizeof(output) && (output.returned.forkattr & ATTR_CMNEXT_EXT_FLAGS); |
| 105 | + row[@"extended_flags"] = @{ @"rc": @(rc), @"errno": rc ? @(errno) : @0, |
| 106 | + @"returned": @(valid), @"value": valid ? @(output.flags) : [NSNull null], |
| 107 | + @"sync_root": valid ? @((output.flags & EF_IS_SYNC_ROOT) != 0) : [NSNull null] }; |
| 108 | + row[@"services"] = Await(^(void (^done)(NSDictionary *)) { |
| 109 | + [[NSFileManager defaultManager] getFileProviderServicesForItemAtURL:url |
| 110 | + completionHandler:^(NSDictionary<NSFileProviderServiceName, NSFileProviderService *> *services, NSError *error) { |
| 111 | + done(@{ @"status": @"callback", @"dictionary_present": @(services != nil), |
| 112 | + @"count": @(services.count), @"error": ErrorCode(error) }); |
| 113 | + }]; |
| 114 | + }); |
| 115 | + row[@"own_provider_lookup"] = Await(^(void (^done)(NSDictionary *)) { |
| 116 | + [NSFileProviderManager getIdentifierForUserVisibleFileAtURL:url |
| 117 | + completionHandler:^(NSFileProviderItemIdentifier item, NSFileProviderDomainIdentifier domain, NSError *error) { |
| 118 | + done(@{ @"status": @"callback", @"item_present": @(item != nil), |
| 119 | + @"domain_present": @(domain != nil), @"error": ErrorCode(error) }); |
| 120 | + }]; |
| 121 | + }); |
| 122 | + struct stat after = {0}; |
| 123 | + rc = lstat(url.fileSystemRepresentation, &after); |
| 124 | + row[@"identity_and_size_unchanged"] = @(!rc && before.st_dev == after.st_dev && |
| 125 | + before.st_ino == after.st_ino && before.st_size == after.st_size && before.st_flags == after.st_flags); |
| 126 | + row[@"unmanaged_classification"] = @"unknown: no proven cross-provider predicate"; |
| 127 | + return row; |
| 128 | +} |
| 129 | + |
| 130 | +int main(int argc, const char *argv[]) { |
| 131 | + @autoreleasepool { |
| 132 | + if (argc != 2) return 64; |
| 133 | + int originalPolicy = getiopolicy_np(IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES, IOPOL_SCOPE_PROCESS); |
| 134 | + int policyRC = setiopolicy_np(IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES, IOPOL_SCOPE_PROCESS, |
| 135 | + IOPOL_MATERIALIZE_DATALESS_FILES_OFF); |
| 136 | + int policyError = policyRC ? errno : 0; |
| 137 | + NSMutableDictionary *report = [@{ |
| 138 | + @"schema": @1, @"runtime": NSProcessInfo.processInfo.operatingSystemVersionString, |
| 139 | + @"app_sandbox_entitlement": @NO, @"metadata_only": @YES, |
| 140 | + @"materialization_policy": @{ @"original": @(originalPolicy), @"set_rc": @(policyRC), |
| 141 | + @"errno": @(policyError), @"observed": @(getiopolicy_np(IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES, IOPOL_SCOPE_PROCESS)) } |
| 142 | + } mutableCopy]; |
| 143 | + if (policyRC) { |
| 144 | + report[@"probe_status"] = @"blocked: cannot disable materialization"; |
| 145 | + } else { |
| 146 | + NSURL *root = [NSURL fileURLWithFileSystemRepresentation:argv[1] isDirectory:YES relativeToURL:nil]; |
| 147 | + NSMutableArray *rows = [NSMutableArray new]; |
| 148 | + for (NSString *name in @[@"ordinary-file", @"ordinary-directory", @"missing-control", @"symlink-control"]) |
| 149 | + [rows addObject:Probe([root URLByAppendingPathComponent:name], name)]; |
| 150 | + report[@"samples"] = rows; |
| 151 | + report[@"probe_status"] = @"completed"; |
| 152 | + } |
| 153 | + int restoreRC = originalPolicy >= 0 ? setiopolicy_np(IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES, |
| 154 | + IOPOL_SCOPE_PROCESS, originalPolicy) : -1; |
| 155 | + report[@"policy_restore_rc"] = @(restoreRC); |
| 156 | + NSError *error = nil; |
| 157 | + NSData *data = [NSJSONSerialization dataWithJSONObject:report options:NSJSONWritingPrettyPrinted | NSJSONWritingSortedKeys error:&error]; |
| 158 | + if (!data) return 70; |
| 159 | + fwrite(data.bytes, 1, data.length, stdout); fputc('\n', stdout); |
| 160 | + return policyRC ? 2 : 0; |
| 161 | + } |
| 162 | +} |
| 163 | +``` |
0 commit comments