Skip to content

Commit 0c9ba31

Browse files
committed
initial
0 parents  commit 0c9ba31

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM debian:stretch-slim AS build0
2+
WORKDIR /root
3+
4+
RUN apt-get update && apt-get install -y binutils gcc
5+
6+
ADD wrapper.c /root/
7+
RUN gcc -shared -ldl -fPIC -o wrapper.so wrapper.c
8+
9+
10+
11+
FROM mcr.microsoft.com/mssql/server
12+
COPY --from=build0 /root/wrapper.so /root/
13+
14+
15+
CMD LD_PRELOAD=/root/wrapper.so /opt/mssql/bin/sqlservr

wrapper.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#define _GNU_SOURCE
2+
#include <sys/sysinfo.h>
3+
#include <dlfcn.h>
4+
#include <stdio.h>
5+
6+
int sysinfo(struct sysinfo *info){
7+
// clear it
8+
//dlerror();
9+
void *pt=NULL;
10+
typedef int (*real_sysinfo)(struct sysinfo *info);
11+
12+
// we need the real sysinfo function address
13+
pt = dlsym(RTLD_NEXT,"sysinfo");
14+
//printf("pt: %x\n", *(char *)pt);
15+
16+
// call the real sysinfo system call
17+
int real_return_val=((real_sysinfo)pt)(info);
18+
19+
// but then modify its returned totalram field if necessary
20+
// because sqlserver needs to believe it has 2GiB physical
21+
// memory
22+
if( info->totalram < 1024l * 1024l * 1024l * 2l){ // 2GiB
23+
info->totalram = 1024l * 1024l * 1024l * 2l ;
24+
}
25+
26+
return real_return_val;
27+
}
28+

0 commit comments

Comments
 (0)