-
-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Code changes to support FreeBSD
- Loading branch information
Showing
2 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -867,11 +867,9 @@ int main(string[] cliArgs) { | |
performFileSystemMonitoring = true; | ||
|
||
// What are the current values for the platform we are running on | ||
// Max number of open files /proc/sys/fs/file-max | ||
string maxOpenFiles = strip(readText("/proc/sys/fs/file-max")); | ||
string maxOpenFiles = strip(getMaxOpenFiles()); | ||
// What is the currently configured maximum inotify watches that can be used | ||
// /proc/sys/fs/inotify/max_user_watches | ||
string maxInotifyWatches = strip(readText("/proc/sys/fs/inotify/max_user_watches")); | ||
string maxInotifyWatches = strip(getMaxInotifyWatches()); | ||
|
||
// Start the monitor process | ||
addLogEntry("OneDrive synchronisation interval (seconds): " ~ to!string(appConfig.getValueLong("monitor_interval"))); | ||
|
@@ -1238,6 +1236,54 @@ int main(string[] cliArgs) { | |
} | ||
} | ||
|
||
// Retrieves the maximum number of open files allowed by the system | ||
string getMaxOpenFiles() { | ||
version (Linux) { | ||
try { | ||
// Read max open files from procfs on Linux | ||
return strip(readText("/proc/sys/fs/file-max")); | ||
} catch (Exception e) { | ||
return "Unknown (Error reading /proc/sys/fs/file-max)"; | ||
} | ||
} else version (FreeBSD) { | ||
try { | ||
// Read max open files using sysctl on FreeBSD | ||
return strip(executeShell("sysctl -n kern.maxfiles").output); | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
maxfiles is not a recognized word. (unrecognized-spelling)
|
||
} catch (Exception e) { | ||
return "Unknown (sysctl error)"; | ||
} | ||
} else version (OpenBSD) { | ||
try { | ||
// Read max open files using sysctl on OpenBSD | ||
return strip(executeShell("sysctl -n kern.maxfiles").output); | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
maxfiles is not a recognized word. (unrecognized-spelling)
|
||
} catch (Exception e) { | ||
return "Unknown (sysctl error)"; | ||
} | ||
} else { | ||
return "Unsupported platform"; | ||
} | ||
} | ||
|
||
// Retrieves the maximum inotify watches allowed (Linux) or a placeholder for other platforms | ||
string getMaxInotifyWatches() { | ||
version (Linux) { | ||
try { | ||
// Read max inotify watches from procfs on Linux | ||
return strip(readText("/proc/sys/fs/inotify/max_user_watches")); | ||
} catch (Exception e) { | ||
return "Unknown (Error reading /proc/sys/fs/inotify/max_user_watches)"; | ||
} | ||
} else version (FreeBSD) { | ||
// FreeBSD uses kqueue instead of inotify, no direct equivalent | ||
return "N/A (uses kqueue)"; | ||
} else version (OpenBSD) { | ||
// OpenBSD uses kqueue instead of inotify, no direct equivalent | ||
return "N/A (uses kqueue)"; | ||
} else { | ||
return "Unsupported platform"; | ||
} | ||
} | ||
|
||
// Print error message when --sync or --monitor has not been used and no valid 'no-sync' operation was requested | ||
void printMissingOperationalSwitchesError() { | ||
// notify the user that --sync or --monitor were missing | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
039abb6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@check-spelling-bot Report
🔴 Please review
See the 📜action log or 📝 job summary for details.
Unrecognized words (1)
maxfiles
To accept these unrecognized words as correct, you could run the following commands
... in a clone of the [email protected]:abraunegg/onedrive.git repository
on the
support-freebsd
branch (ℹ️ how do I use this?):