Initial import
[samba] / source / smbwrapper / PORTING
1 This describes how to port the smbwrapper portion of Samba to a new
2 unix-like platform. Note that porting smbwrapper is considerably
3 harder than porting Samba, for Samba you generally just need to run
4 configure and recompile whereas for smbwrapper some extra effort is
5 generally required.
6
7
8 STEP 1
9 ------
10
11 The first step is to work out how to create a shared library on your
12 OS and how to compile C code to produce position independent object
13 files (PIC files). You shoud be able to find this information in the
14 man pages for your compiler and loader (ld). Then modify configure.in
15 to give that information to Samba.
16
17
18 STEP 2
19 ------
20
21 The next step is to work out how to preload shared objects. On many
22 systems this is done using a LD_PRELOAD environment variable. On
23 others (shc as IRIX) it may use a _RTL_LIST variable.
24
25 To make sure it works I suggest you create two C files like this:
26
27 /* first C file */
28 main()
29 {
30  unlink("foo.txt");
31 }
32
33 /* second C file */
34 #include <stdio.h>
35
36 int unlink(char *fname)
37 {
38         fprintf(stderr,"unlink(%s) called\n",fname);
39 }
40
41
42 then compile the first as an ordinary C program and the second as a
43 shared library. Then use LD_PRELOAD to preload the resulting shared
44 library. Then run the first program. It should print "unlink(foo.txt)
45 called". If it doesn't then consult your man pages till you get it
46 right.
47
48 Once you work this out then edit smbwrapper/smbsh.in and add a section
49 if necessary to correctly set the necessary preload options for your
50 OS. 
51
52
53 STEP 3
54 ------
55
56 The next step is to work out how to make direct system calls. On most
57 machines this will work without any source code changes to
58 smbwrapper. To test that it does work create the following C program:
59
60 #include <sys/syscall.h>
61 main()
62 {
63  syscall(SYS_write, 1, "hello world\n", 12);
64 }
65
66 and try to compile/run it. If it produces "hello world" then syscall()
67 works as expected. If not then work out what needs to be changed and
68 then make that change in realcalls.h. For example, on IRIX 6.4 the
69 system call numbers are wrong and need to be fixed up by getting an
70 offset right.
71
72
73 STEP 4
74 ------
75
76 Try compiling smbwrapper! Then test it. Then debug it. Simple really :)
77