File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments