forked from justin2004/mssql_server_tiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapper.c
28 lines (22 loc) · 762 Bytes
/
wrapper.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#define _GNU_SOURCE
#include <sys/sysinfo.h>
#include <dlfcn.h>
#include <stdio.h>
int sysinfo(struct sysinfo *info){
// clear it
//dlerror();
void *pt=NULL;
typedef int (*real_sysinfo)(struct sysinfo *info);
// we need the real sysinfo function address
pt = dlsym(RTLD_NEXT,"sysinfo");
//printf("pt: %x\n", *(char *)pt);
// call the real sysinfo system call
int real_return_val=((real_sysinfo)pt)(info);
// but then modify its returned totalram field if necessary
// because sqlserver needs to believe it has "2000 megabytes"
// physical memory
if( info->totalram < 1000l * 1000l * 1000l * 2l){ // 2000 megabytes
info->totalram = 1000l * 1000l * 1000l * 2l ;
}
return real_return_val;
}