Skip to content

Commit

Permalink
o Increment build to 509. It will be 510 on release. Going forward od…
Browse files Browse the repository at this point in the history
…d numbered builds are my in process dev, even are the actual releases.

o Tweak some locking timeout values
o Modify portions of iOSFS.m to timeout rather than lockup when iOSFS is being stupid
  • Loading branch information
Mike Miller committed Jan 1, 2024
1 parent fe21c7c commit 673f710
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 35 deletions.
69 changes: 50 additions & 19 deletions app/iOSFS.m
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,33 @@ static ssize_t iosfs_readlink(struct mount *mount, const char *path, char *buf,
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
NSURL *in_url = url_for_path_in_mount(mount, path);

NSError *error;
__block ssize_t size;
__block NSError *error = nil;
__block ssize_t size = -1;
dispatch_semaphore_t sem = dispatch_semaphore_create(0);

// Define a timeout duration
dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC);

// Move the file coordination to a background queue
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[coordinator coordinateReadingItemAtURL:in_url options:NSFileCoordinatorReadingWithoutChanges error:&error byAccessor:^(NSURL *url) {
size = realfs.readlink(mount, path_for_url_in_mount(mount, url, path), buf, bufsize);
dispatch_semaphore_signal(sem);
}];
});

[coordinator coordinateReadingItemAtURL:in_url options:NSFileCoordinatorReadingWithoutChanges error:&error byAccessor:^(NSURL *url) {
size = realfs.readlink(mount, path_for_url_in_mount(mount, url, path), buf, bufsize);
}];
// Wait for the semaphore with a timeout
if (dispatch_semaphore_wait(sem, timeout) != 0) {
// Handle the timeout case
size = _ETIMEDOUT;
}

// Check and handle any error occurred during file coordination
int posix_error = posixErrorFromNSError(error);
return posix_error ? posix_error : size;
}


static int iosfs_getpath(struct fd *fd, char *buf) {
return realfs.getpath(fd, buf);
}
Expand Down Expand Up @@ -416,17 +432,24 @@ static int iosfs_rmdir(struct mount *mount, const char *path) {
}

static int iosfs_stat(struct mount *mount, const char *path, struct statbuf *fake_stat) {
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
NSURL *in_url = url_for_path_in_mount(mount, path);

NSError *error;
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
__block NSError *error;
__block int err;

[coordinator coordinateReadingItemAtURL:in_url options:NSFileCoordinatorReadingWithoutChanges error:&error byAccessor:^(NSURL *url) {
err = realfs.stat(mount, path_for_url_in_mount(mount, url, path), fake_stat);
}];
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
[coordinator coordinateReadingItemAtURL:in_url options:NSFileCoordinatorReadingWithoutChanges error:&error byAccessor:^(NSURL *url) {
err = realfs.stat(mount, path_for_url_in_mount(mount, url, path), fake_stat);
dispatch_semaphore_signal(sem);
}];
});

return combine_error(error, err);
dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);

dispatch_semaphore_wait(sem, timeout);
return posixErrorFromNSError(error) ?: err;
}

static int iosfs_fstat(struct fd *fd, struct statbuf *fake_stat) {
Expand All @@ -435,17 +458,25 @@ static int iosfs_fstat(struct fd *fd, struct statbuf *fake_stat) {
}

static int iosfs_utime(struct mount *mount, const char *path, struct timespec atime, struct timespec mtime) {
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
NSURL *in_url = url_for_path_in_mount(mount, path);

NSError *error;
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
__block NSError *error;
__block int err;

[coordinator coordinateWritingItemAtURL:in_url options:NSFileCoordinatorWritingContentIndependentMetadataOnly error:&error byAccessor:^(NSURL *url) {
err = realfs.utime(mount, path_for_url_in_mount(mount, url, path), atime, mtime);
}];
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
[coordinator coordinateWritingItemAtURL:in_url options:NSFileCoordinatorWritingContentIndependentMetadataOnly error:&error byAccessor:^(NSURL *url) {
err = realfs.utime(mount, path_for_url_in_mount(mount, url, path), atime, mtime);
dispatch_semaphore_signal(sem);
}];
});

// Define a timeout of 5 seconds
dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);

return combine_error(error, err);
dispatch_semaphore_wait(sem, timeout);
return posixErrorFromNSError(error) ?: err;
}

static int iosfs_mkdir(struct mount *mount, const char *path, mode_t_ mode) {
Expand Down
4 changes: 2 additions & 2 deletions debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <stdio.h>
#include <stdlib.h>

#define WAIT_SLEEP 2000 // Was 25 for a long time. -mke
#define WAIT_MAX_UPPER 555000
#define WAIT_SLEEP 200 // Was 25 for a long time. -mke
#define WAIT_MAX_UPPER 55500

void ish_printk(const char *msg, ...);
void ish_vprintk(const char *msg, va_list args);
Expand Down
24 changes: 12 additions & 12 deletions iSH-AOK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2576,7 +2576,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -2602,7 +2602,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -2637,7 +2637,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -2661,7 +2661,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = "app.ish.iSH-AOK";
Expand All @@ -2686,7 +2686,7 @@
CODE_SIGN_ENTITLEMENTS = app/FileProvider/iSHFileProvider.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
INFOPLIST_FILE = app/FileProvider/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "app.ish.iSH-AOK.FileProvider";
Expand Down Expand Up @@ -2797,7 +2797,7 @@
CODE_SIGN_ENTITLEMENTS = app/FileProvider/iSHFileProvider.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
INFOPLIST_FILE = app/FileProvider/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "app.ish.iSH-AOK.FileProvider";
Expand All @@ -2815,7 +2815,7 @@
CODE_SIGN_ENTITLEMENTS = iSHFileProviderRelease.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
INFOPLIST_FILE = app/FileProvider/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "app.ish.iSH-AOK.FileProvider";
Expand Down Expand Up @@ -2918,7 +2918,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = "app.ish.iSH-AOK";
Expand All @@ -2933,7 +2933,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = "app.ish.iSH-AOK";
Expand Down Expand Up @@ -2961,7 +2961,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -2984,7 +2984,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = "app.ish.iSH-AOK";
Expand All @@ -3009,7 +3009,7 @@
CODE_SIGN_ENTITLEMENTS = app/FileProvider/iSHFileProvider.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 508;
CURRENT_PROJECT_VERSION = 509;
DEVELOPMENT_TEAM = UYU5FM4LQ4;
INFOPLIST_FILE = app/FileProvider/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "app.ish.iSH-AOK.FileProvider";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Locations>
<Location
uuid = "035095F5-47C6-49AD-8C66-AFEF7229BBBE - dc2f8c5e001177f0"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "UIApplicationMain"
Expand All @@ -34,7 +34,7 @@
</Location>
<Location
uuid = "035095F5-47C6-49AD-8C66-AFEF7229BBBE - ed0225d50b1c0976"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "UIKit.UIApplicationMain(Swift.Int32, Swift.Optional&lt;Swift.UnsafeMutablePointer&lt;Swift.UnsafeMutablePointer&lt;Swift.Int8&gt;&gt;&gt;, Swift.Optional&lt;Swift.String&gt;, Swift.Optional&lt;Swift.String&gt;) -&gt; Swift.Int32"
Expand Down
1 change: 1 addition & 0 deletions kernel/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ inline void task_ref_cnt_mod(struct task *task, int value) { // value Should onl
}

if(task == NULL) {
return;
if(current != NULL) {
task = current;
} else {
Expand Down

0 comments on commit 673f710

Please sign in to comment.