this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement getting proc_uniqidentifierinfo via sys_proc_info()

+66 -1
+5
src/kernel/emulation/linux/elfcalls_wrapper.c
··· 43 43 return _elfcalls->dlclose(module); 44 44 } 45 45 46 + const uint8_t* get_exe_uuid(void) 47 + { 48 + return _elfcalls->exe_uuid(); 49 + } 50 +
+2
src/kernel/emulation/linux/elfcalls_wrapper.h
··· 23 23 24 24 void* __darling_thread_get_stack(void); 25 25 26 + const uint8_t* get_exe_uuid(void); 27 + 26 28 #ifdef __cplusplus 27 29 } 28 30 #endif
+59 -1
src/kernel/emulation/linux/misc/proc_info.c
··· 14 14 #include "../unistd/getgid.h" 15 15 #include "../simple.h" 16 16 #include "../readline.h" 17 + #include "../elfcalls_wrapper.h" 17 18 #include <stdbool.h> 18 19 #include <sys/proc.h> 19 20 #include "sysctl_proc.h" ··· 105 106 106 107 static long _proc_pidonfo_uniqinfo(int32_t pid, void* buffer, int32_t bufsize) 107 108 { 109 + #ifndef VARIANT_DYLD 110 + char path[64], stat[1024]; 111 + char *statptr; 112 + const char* elem; 113 + unsigned long long starttime; 114 + int32_t ppid; 115 + 108 116 struct proc_uniqidentifierinfo* info = (struct proc_uniqidentifierinfo*) buffer; 117 + 109 118 if (bufsize < sizeof(*info)) 110 119 return -ENOSPC; 111 120 112 121 memset(buffer, 0, bufsize); 113 122 114 - return -ENOTSUP; 123 + memcpy(info->p_uuid, get_exe_uuid, sizeof(info->p_uuid)); 124 + 125 + ////////////////////////// 126 + // Read info for pid // 127 + ////////////////////////// 128 + 129 + __simple_sprintf(path, "/proc/%d/stat", pid); 130 + if (!read_string(path, stat, sizeof(stat))) 131 + return -ESRCH; 132 + 133 + statptr = stat; 134 + skip_stat_elems(&statptr, 3); // skip until ppid 135 + 136 + elem = next_stat_elem(&statptr); 137 + if (!elem) 138 + return -EINVAL; 139 + 140 + ppid = __simple_atoi(elem, NULL); 141 + 142 + skip_stat_elems(&statptr, 17); // skip until starttime 143 + elem = next_stat_elem(&statptr); 144 + 145 + if (!elem) 146 + return -EINVAL; 147 + 148 + starttime = __simple_atoi(elem, NULL); 149 + info->p_uniqueid = starttime << 16; 150 + info->p_uniqueid |= (pid & 0xffff); 151 + 152 + ////////////////////////// 153 + // Read info for ppid // 154 + ////////////////////////// 155 + 156 + __simple_sprintf(path, "/proc/%d/stat", ppid); 157 + if (!read_string(path, stat, sizeof(stat))) 158 + return -ESRCH; 159 + 160 + statptr = stat; 161 + skip_stat_elems(&statptr, 21); // skip until starttime 162 + elem = next_stat_elem(&statptr); 163 + 164 + if (!elem) 165 + return -EINVAL; 166 + 167 + starttime = __simple_atoi(elem, NULL); 168 + info->p_puniqueid = starttime << 16; 169 + info->p_puniqueid |= (ppid & 0xffff); 170 + 171 + #endif 172 + return 0; 115 173 } 116 174 117 175 static long _proc_pidinfo_shortbsdinfo(int32_t pid, void* buffer, int32_t bufsize)