Skip to content

Commit

Permalink
o Added /proc/ish/device_info
Browse files Browse the repository at this point in the history
[ish@myipad9 ~ 95%(C)] $ cat /proc/ish/device_info
Host OS Name: Darwin
Host OS Release: 23.1.0
Host OS Version: Darwin Kernel Version 23.1.0: Tue Oct 10 02:21:48 PDT 2023; root:xnu-10002.42.9~2/RELEASE_ARM64_T8030
Host Hardware: iPad 9th Gen (WiFi)
  • Loading branch information
Mike Miller committed Dec 25, 2023
1 parent 10088a3 commit b7a5b11
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 3 deletions.
7 changes: 7 additions & 0 deletions fs/proc/ish.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ static int proc_ish_show_version(struct proc_entry *UNUSED(entry), struct proc_d
}

extern char* printBatteryStatus(int type);
extern char* printDeviceInfo(void);

static int proc_ish_show_device_info(struct proc_entry *UNUSED(entry), struct proc_data *buf) {
proc_printf(buf, "%s", printDeviceInfo());
return 0;
}

static int proc_ish_show_battery(struct proc_entry *UNUSED(entry), struct proc_data *buf) {
proc_printf(buf, "%s", printBatteryStatus(3));
Expand Down Expand Up @@ -303,6 +309,7 @@ struct proc_children proc_ish_children = PROC_CHILDREN({
{"BAT0_status", .show = proc_ish_show_battery_status},
{"UIDevice", .show = proc_ish_show_uidevice},
{"colors", .show = proc_ish_show_colors},
{"device_info", .show = proc_ish_show_device_info},
{".defaults", S_IFDIR, .readdir = proc_ish_underlying_defaults_readdir},
{"defaults", S_IFDIR, .readdir = proc_ish_defaults_readdir},
{"documents", .show = proc_ish_show_documents},
Expand Down
10 changes: 10 additions & 0 deletions iSH-AOK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
497F6D3D254E5EA600C82F46 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = BB7D93822087C2890008DA78 /* main.c */; };
497F6D5C254E609700C82F46 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = BB7D93822087C2890008DA78 /* main.c */; };
497F6D87254E62E100C82F46 /* libish.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BB13F7DC200AD81D003D1C4D /* libish.a */; };
5D3D34812B39C83100CF8779 /* DeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D3D34802B39C83100CF8779 /* DeviceInfo.m */; };
5D3D34822B39C83100CF8779 /* DeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D3D34802B39C83100CF8779 /* DeviceInfo.m */; };
5D3D34832B39C83100CF8779 /* DeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D3D34802B39C83100CF8779 /* DeviceInfo.m */; };
5D4E7DF82B1E68EB006BA7D4 /* ro_locks.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D59DADB2B179A2300FA995C /* ro_locks.c */; };
5D4E7DFA2B1E68F6006BA7D4 /* rw_locks.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D59DAE32B17EB1600FA995C /* rw_locks.c */; };
5D7E7E152B1FD4890087F2E0 /* ro_locks.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D59DADB2B179A2300FA995C /* ro_locks.c */; };
Expand Down Expand Up @@ -590,6 +593,8 @@
497F6CE4254E5E4C00C82F46 /* MakeXcodeAutoCompleteWork */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MakeXcodeAutoCompleteWork; sourceTree = BUILT_PRODUCTS_DIR; };
497F6D47254E605F00C82F46 /* ish-AOK */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = "ish-AOK"; path = ish; sourceTree = BUILT_PRODUCTS_DIR; };
5D272493277C20DF0005F2A8 /* iSHFileProviderRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = iSHFileProviderRelease.entitlements; sourceTree = "<group>"; };
5D3D347F2B39C7CA00CF8779 /* DeviceInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeviceInfo.h; sourceTree = "<group>"; };
5D3D34802B39C83100CF8779 /* DeviceInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DeviceInfo.m; sourceTree = "<group>"; };
5D59DAD92B17996100FA995C /* ro_locks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ro_locks.h; sourceTree = "<group>"; };
5D59DADA2B17999500FA995C /* rw_locks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rw_locks.h; sourceTree = "<group>"; };
5D59DADB2B179A2300FA995C /* ro_locks.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ro_locks.c; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1189,7 +1194,9 @@
497F6C79254E5C9700C82F46 /* vdso.c */,
497F6C84254E5C9700C82F46 /* vdso.h */,
5DA0A8332AAE21D000397280 /* BatteryStatus.m */,
5D3D34802B39C83100CF8779 /* DeviceInfo.m */,
5DA0A8352AAE224100397280 /* BatteryStatus.h */,
5D3D347F2B39C7CA00CF8779 /* DeviceInfo.h */,
5DD383EA2AAE33330013A847 /* UIDevice.m */,
5DD383EC2AAE33920013A847 /* UIDevice.h */,
);
Expand Down Expand Up @@ -2107,6 +2114,7 @@
497F6D30254E5EA600C82F46 /* resource.c in Sources */,
497F6D31254E5EA600C82F46 /* signal.c in Sources */,
497F6D32254E5EA600C82F46 /* task.c in Sources */,
5D3D34832B39C83100CF8779 /* DeviceInfo.m in Sources */,
497F6D33254E5EA600C82F46 /* time.c in Sources */,
497F6D34254E5EA600C82F46 /* tls.c in Sources */,
497F6D35254E5EA600C82F46 /* uname.c in Sources */,
Expand Down Expand Up @@ -2144,6 +2152,7 @@
5DA0A8342AAE21D000397280 /* BatteryStatus.m in Sources */,
5D8CFA852B1198B300D50E57 /* RTCDevice.m in Sources */,
5DD383EB2AAE33330013A847 /* UIDevice.m in Sources */,
5D3D34812B39C83100CF8779 /* DeviceInfo.m in Sources */,
BB28C7BB268975AE00BDC834 /* LocationDevice.m in Sources */,
5D8ACEFD284CE096003C50D3 /* sys.c in Sources */,
BB28C7BA268975AA00BDC834 /* iOSFS.m in Sources */,
Expand All @@ -2166,6 +2175,7 @@
buildActionMask = 2147483647;
files = (
BB88F49A2154760800A341FD /* FileProviderEnumerator.m in Sources */,
5D3D34822B39C83100CF8779 /* DeviceInfo.m in Sources */,
BBBFE94921C5CFF100509DD5 /* NSError+ISHErrno.m in Sources */,
BB9C7B87240A2B1E00F5D4F0 /* AppGroup.m in Sources */,
5D8CFA872B1198B300D50E57 /* RTCDevice.m in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions kernel/BatteryStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#ifndef BatteryStatus_h
#define BatteryStatus_h


#endif /* BatteryStatus_h */
// BatteryStatus.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

char* printBatteryStatus(int type);

#endif /* BatteryStatus_h */

16 changes: 16 additions & 0 deletions kernel/DeviceInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// DeviceInfo.h
// iSH-AOK
//
// Created by Michael Miller on 12/25/23.
//

#ifndef DeviceInfo_h
#define DeviceInfo_h

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

char* printDeviceInfo(int type);

#endif /* DeviceInfo_h */
148 changes: 148 additions & 0 deletions kernel/DeviceInfo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
//
// DeviceInfo.m
// iSH-AOK
//
// Created by Michael Miller on 12/25/23.
//

#import <Foundation/Foundation.h>
#import <sys/utsname.h>

NSString* translateDeviceIdentifier(NSString *identifier) {
NSDictionary<NSString *, NSString *> *deviceNames = @{
// iPhones with 64-bit Processors
@"iPhone6,1": @"iPhone 5S (GSM)",
@"iPhone6,2": @"iPhone 5S (Global)",
@"iPhone7,1": @"iPhone 6 Plus",
@"iPhone7,2": @"iPhone 6",
@"iPhone8,1": @"iPhone 6s",
@"iPhone8,2": @"iPhone 6s Plus",
@"iPhone8,4": @"iPhone SE (GSM)",
@"iPhone9,1": @"iPhone 7",
@"iPhone9,2": @"iPhone 7 Plus",
@"iPhone9,3": @"iPhone 7",
@"iPhone9,4": @"iPhone 7 Plus",
@"iPhone10,1" : @"iPhone 8",
@"iPhone10,2": @"iPhone 8 Plus",
@"iPhone10,3": @"iPhone X Global",
@"iPhone10,4": @"iPhone 8",
@"iPhone10,5": @"iPhone 8 Plus",
@"iPhone10,6": @"iPhone X GSM",
@"iPhone11,2": @"iPhone XS",
@"iPhone11,4": @"iPhone XS Max",
@"iPhone11,6": @"iPhone XS Max Global",
@"iPhone11,8": @"iPhone XR",
@"iPhone12,1": @"iPhone 11",
@"iPhone12,3": @"iPhone 11 Pro",
@"iPhone12,5": @"iPhone 11 Pro Max",
@"iPhone12,8": @"iPhone SE 2nd Gen",
@"iPhone13,1": @"iPhone 12 Mini",
@"iPhone13,2": @"iPhone 12",
@"iPhone13,3": @"iPhone 12 Pro",
@"iPhone13,4": @"iPhone 12 Pro Max",
@"iPhone14,2": @"iPhone 13 Pro",
@"iPhone14,3": @"iPhone 13 Pro Max",
@"iPhone14,4": @"iPhone 13 Mini",
@"iPhone14,5": @"iPhone 13",
@"iPhone14,6": @"iPhone SE 3rd Gen",
@"iPhone14,7": @"iPhone 14",
@"iPhone14,8": @"iPhone 14 Plus",
@"iPhone15,2": @"iPhone 14 Pro",
@"iPhone15,3": @"iPhone 14 Pro Max",
@"iPhone15,4": @"iPhone 15",
@"iPhone15,5": @"iPhone 15 Plus",
@"iPhone16,1": @"iPhone 15 Pro",
@"iPhone16,2": @"iPhone 15 Pro Max",
// iPads with 64-bit Processors
@"iPad4,1": @"iPad Air (WiFi)",
@"iPad4,2": @"iPad Air (GSM+CDMA)",
@"iPad4,3": @"1st Gen iPad Air (China)",
@"iPad4,4": @"iPad mini Retina (WiFi)",
@"iPad4,5": @"iPad mini Retina (GSM+CDMA)",
@"iPad4,6": @"iPad mini Retina (China)",
@"iPad4,7": @"iPad mini 3 (WiFi)",
@"iPad4,8": @"iPad mini 3 (GSM+CDMA)",
@"iPad4,9": @"iPad Mini 3 (China)",
@"iPad5,1": @"iPad mini 4 (WiFi)",
@"iPad5,2": @"4th Gen iPad mini (WiFi+Cellular)",
@"iPad5,3": @"iPad Air 2 (WiFi)",
@"iPad5,4": @"iPad Air 2 (Cellular)",
@"iPad6,3": @"iPad Pro (9.7 inch, WiFi)",
@"iPad6,4": @"iPad Pro (9.7 inch, WiFi+LTE)",
@"iPad6,7": @"iPad Pro (12.9 inch, WiFi)",
@"iPad6,8": @"iPad Pro (12.9 inch, WiFi+LTE)",
@"iPad7,3": @"iPad Pro 10.5-inch 2nd Gen",
@"iPad7,4": @"iPad Pro 10.5-inch 2nd Gen",
@"iPad7,5": @"iPad 6th Gen (WiFi)",
@"iPad7,6": @"iPad 6th Gen (WiFi+Cellular)",
@"iPad7,11": @"iPad 7th Gen 10.2-inch (WiFi)",
@"iPad7,12": @"iPad 7th Gen 10.2-inch (WiFi+Cellular)",
@"iPad8,1": @"iPad Pro 11 inch 3rd Gen (WiFi)",
@"iPad8,2": @"iPad Pro 11 inch 3rd Gen (1TB, WiFi)",
@"iPad8,3": @"iPad Pro 11 inch 3rd Gen (WiFi+Cellular)",
@"iPad8,4": @"iPad Pro 11 inch 3rd Gen (1TB, WiFi+Cellular)",
@"iPad8,5": @"iPad Pro 12.9 inch 3rd Gen (WiFi)",
@"iPad8,6": @"iPad Pro 12.9 inch 3rd Gen (1TB, WiFi)",
@"iPad8,7": @"iPad Pro 12.9 inch 3rd Gen (WiFi+Cellular)",
@"iPad8,8": @"iPad Pro 12.9 inch 3rd Gen (1TB, WiFi+Cellular)",
@"iPad8,9": @"iPad Pro 11 inch 4th Gen (WiFi)",
@"iPad8,10": @"iPad Pro 11 inch 4th Gen (WiFi+Cellular)",
@"iPad8,11": @"iPad Pro 12.9 inch 4th Gen (WiFi)",
@"iPad8,12": @"iPad Pro 12.9 inch 4th Gen (WiFi+Cellular)",
@"iPad11,1": @"iPad mini 5th Gen (WiFi)",
@"iPad11,2": @"iPad mini 5th Gen",
@"iPad11,3": @"iPad Air 3rd Gen (WiFi)",
@"iPad11,4": @"iPad Air 3rd Gen",
@"iPad11,6": @"iPad 8th Gen (WiFi)",
@"iPad11,7": @"iPad 8th Gen (WiFi+Cellular)",
@"iPad12,1": @"iPad 9th Gen (WiFi)",
@"iPad12,2": @"iPad 9th Gen (WiFi+Cellular)",
@"iPad14,1": @"iPad mini 6th Gen (WiFi)",
@"iPad14,2": @"iPad mini 6th Gen (WiFi+Cellular)",
@"iPad13,1": @"iPad Air 4th Gen (WiFi)",
@"iPad13,2": @"iPad Air 4th Gen (WiFi+Cellular)",
@"iPad13,4": @"iPad Pro 11 inch 5th Gen",
@"iPad13,5": @"iPad Pro 11 inch 5th Gen",
@"iPad13,6": @"iPad Pro 11 inch 5th Gen",
@"iPad13,7": @"iPad Pro 11 inch 5th Gen",
@"iPad13,8": @"iPad Pro 12.9 inch 5th Gen",
@"iPad13,9": @"iPad Pro 12.9 inch 5th Gen",
@"iPad13,10": @"iPad Pro 12.9 inch 5th Gen",
@"iPad13,11": @"iPad Pro 12.9 inch 5th Gen",
@"iPad13,16": @"iPad Air 5th Gen (WiFi)",
@"iPad13,17": @"iPad Air 5th Gen (WiFi+Cellular)",
@"iPad13,18": @"iPad 10th Gen",
@"iPad13,19": @"iPad 10th Gen",
@"iPad14,3": @"iPad Pro 11 inch 4th Gen",
@"iPad14,4": @"iPad Pro 11 inch 4th Gen",
@"iPad14,5": @"iPad Pro 12.9 inch 6th Gen",
@"iPad14,6": @"iPad Pro 12.9 inch 6th Gen",
};

NSString *deviceName = deviceNames[identifier];
if (deviceName) {
return deviceName;
} else {
return identifier; // Return the original identifier if no mapping is found
}
}


char* printDeviceInfo(void) {
struct utsname systemInfo;
uname(&systemInfo);

NSString *machineIdentifier = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
NSString *translatedMachine = translateDeviceIdentifier(machineIdentifier);

// Create an NSString with formatted device info
NSString *deviceInfo = [NSString stringWithFormat:@"Host OS Name: %s\nHost OS Release: %s\nHost OS Version: %s\nHost Hardware: %@\n",
systemInfo.sysname, // Operating system name (e.g., Darwin)
systemInfo.release, // Operating system release (e.g., 20.3.0)
systemInfo.version, // Operating system version
translatedMachine]; // Translated hardware identifier

// Convert NSString to C-string
char *cString = strdup([deviceInfo UTF8String]);
return cString;
}

0 comments on commit b7a5b11

Please sign in to comment.