GPLONLY_ and PID-related stuff
This commit is contained in:
30
proc/ksym.c
30
proc/ksym.c
@@ -140,7 +140,7 @@ static unsigned idx_room;
|
||||
* /proc/ksyms and System.map data files.
|
||||
*/
|
||||
#if 0
|
||||
static void chop_version(char *arg){
|
||||
static char *chop_version(char *arg){
|
||||
char *cp;
|
||||
cp = strchr(arg,'\t');
|
||||
if(cp) *cp = '\0'; /* kill trailing module name first */
|
||||
@@ -152,7 +152,7 @@ static void chop_version(char *arg){
|
||||
for(p=cp; *++p; ){
|
||||
switch(*p){
|
||||
default:
|
||||
return;
|
||||
goto out;
|
||||
case '0' ... '9':
|
||||
case 'a' ... 'f':
|
||||
len++;
|
||||
@@ -166,9 +166,18 @@ static void chop_version(char *arg){
|
||||
if(len<8) break;
|
||||
cp[-1] = '\0';
|
||||
}
|
||||
out:
|
||||
if(*arg=='G'){
|
||||
int len = strlen(arg);
|
||||
while( len>8 && !memcmp(arg,"GPLONLY_",8) ){
|
||||
arg += 8;
|
||||
len -= 8;
|
||||
}
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
#endif
|
||||
static void chop_version(char *arg){
|
||||
static char *chop_version(char *arg){
|
||||
char *cp;
|
||||
cp = strchr(arg,'\t');
|
||||
if(cp) *cp = '\0'; /* kill trailing module name first */
|
||||
@@ -182,6 +191,14 @@ static void chop_version(char *arg){
|
||||
if(strspn(cp+len-8,"0123456789abcdef")!=8) break;
|
||||
cp[-1] = '\0';
|
||||
}
|
||||
if(*arg=='G'){
|
||||
int len = strlen(arg);
|
||||
while( len>8 && !memcmp(arg,"GPLONLY_",8) ){
|
||||
arg += 8;
|
||||
len -= 8;
|
||||
}
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
@@ -293,12 +310,11 @@ bypass:
|
||||
ksyms_index[ksyms_count].addr = STRTOUKL(endp, &endp, 16);
|
||||
if(endp==saved || *endp != ' ') goto bad_parse;
|
||||
endp++;
|
||||
ksyms_index[ksyms_count].name = endp;
|
||||
saved = endp;
|
||||
endp = strchr(endp,'\n');
|
||||
if(!endp) goto bad_parse; /* no newline */
|
||||
*endp = '\0';
|
||||
chop_version(saved);
|
||||
ksyms_index[ksyms_count].name = chop_version(saved);
|
||||
++endp;
|
||||
if(++ksyms_count >= idx_room) break; /* need more space */
|
||||
}
|
||||
@@ -400,13 +416,13 @@ good_match:;
|
||||
endp++;
|
||||
if(*endp != ' ') goto bad_parse;
|
||||
endp++;
|
||||
sysmap_index[sysmap_count].name = endp;
|
||||
vstart = endp;
|
||||
endp = strchr(endp,'\n');
|
||||
if(!endp) goto bad_parse; /* no newline */
|
||||
*endp = '\0';
|
||||
++endp;
|
||||
chop_version(vstart);
|
||||
vstart = chop_version(vstart);
|
||||
sysmap_index[sysmap_count].name = vstart;
|
||||
if(*vstart=='V' && *Version && !strcmp(Version,vstart)) *Version='\0';
|
||||
if(++sysmap_count >= sysmap_room) break; /* need more space */
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ global:
|
||||
Hertz; smp_num_cpus;
|
||||
sprint_uptime; uptime; user_from_uid; print_uptime; loadavg;
|
||||
pretty_print_signals; print_given_signals; unix_print_signals; signal_name_to_number; signal_number_to_name;
|
||||
meminfo; vminfo; getstat; getdiskstat; getslabinfo;
|
||||
meminfo; vminfo; getstat; getdiskstat; getslabinfo; get_pid_digits;
|
||||
kb_active; kb_inactive; kb_main_buffers; kb_main_cached;
|
||||
kb_main_free; kb_main_total; kb_main_used; kb_swap_free;
|
||||
kb_swap_total; kb_swap_used; kb_main_shared;
|
||||
|
@@ -734,8 +734,8 @@ HIDDEN_ALIAS(readproc);
|
||||
|
||||
/* Convenient wrapper around openproc and readproc to slurp in the whole process
|
||||
* table subset satisfying the constraints of flags and the optional PID list.
|
||||
* Free allocated memory with freeproctab(). Access via tab[N]->member. The
|
||||
* pointer list is NULL terminated.
|
||||
* Free allocated memory with exit(). Access via tab[N]->member. The pointer
|
||||
* list is NULL terminated.
|
||||
*/
|
||||
proc_t** readproctab(int flags, ...) {
|
||||
PROCTAB* PT = NULL;
|
||||
|
@@ -166,8 +166,8 @@ extern PROCTAB* openproc(int flags, ... /* pid_t*|uid_t*|dev_t*|char* [, int n]
|
||||
|
||||
/* Convenient wrapper around openproc and readproc to slurp in the whole process
|
||||
* table subset satisfying the constraints of flags and the optional PID list.
|
||||
* Free allocated memory with freeproctab(). Access via tab[N]->member. The
|
||||
* pointer list is NULL terminated.
|
||||
* Free allocated memory with exit(). Access via tab[N]->member. The pointer
|
||||
* list is NULL terminated.
|
||||
*/
|
||||
extern proc_t** readproctab(int flags, ... /* same as openproc */ );
|
||||
|
||||
|
@@ -757,3 +757,32 @@ unsigned int getslabinfo (struct slab_cache **slab){
|
||||
return cSlab;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
unsigned get_pid_digits(void){
|
||||
char buf[24];
|
||||
char *endp;
|
||||
long rc;
|
||||
int fd;
|
||||
static unsigned ret;
|
||||
|
||||
if(ret) goto out;
|
||||
ret = 5;
|
||||
fd = open("/proc/sys/kernel/pid_max", O_RDONLY);
|
||||
if(fd==-1) goto out;
|
||||
rc = read(fd, buf, sizeof buf);
|
||||
close(fd);
|
||||
if(rc<3) goto out;
|
||||
buf[rc] = '\0';
|
||||
rc = strtol(buf,&endp,10);
|
||||
if(rc<42) goto out;
|
||||
if(*endp && *endp!='\n') goto out;
|
||||
rc--; // the pid_max value is really the max PID plus 1
|
||||
ret = 0;
|
||||
while(rc){
|
||||
rc /= 10;
|
||||
ret++;
|
||||
}
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
@@ -127,5 +127,7 @@ typedef struct slab_cache{
|
||||
|
||||
extern unsigned int getslabinfo (struct slab_cache**);
|
||||
|
||||
extern unsigned get_pid_digits(void) FUNCTION;
|
||||
|
||||
EXTERN_C_END
|
||||
#endif /* SYSINFO_H */
|
||||
|
Reference in New Issue
Block a user