Samba 3.0.22 Porting by Vidya Sagar

6
1.A.2 MPE/iX Libraries
Normally, an application required to be linked with many libraries. Some application requires library only at compile time
and some at runtime as well. Say for example Samba requires the POSIX wrappers at runtime also; hence it becomes
necessary to include the runtime library into the package.
MPE/iX system libraries are available in two types NMRL archive library and NMXL shared library. NMRL and NMXL are
available in MPE namespace in as NL.PUB.SYS and XL.PUB.SYS and both contain all the routines available in various
assorted libraries in /lib and /usr/lib directories. The libraries available at /lib and /usr/lib are system and C libraries. An
application is linked by default with C libraries whenever required. To link with specific libraries programmer need to tell
the name of library using “-l’ flag and their search path using “-L” flag. Samba requires to be linked with following libraries
apart from the default libraries:
/POSIXC60/lib/libsocket.a
/POSIXC60/lib/libunix.a
/usr/lib/socket.a
/lib/libsvipc.a
/usr/lib/libcurses.a
/SYSLOG/PUB/libsyslog.a
You need to specify the libraries by -lposix60 -lunix -lsyslog -lsocket -lsvipc –lcurses and additional
search path apart from default search path by –L/POSIXC60/lib –L/SYSLOG/PUB. Compiler by default searches for
libraries in /lib and /usr/lib. By specifying –Ldir, compiler is being told to search in the directory “dir” in addition to the
default search path for the libraries specified by –l oprtion.
The compiler option –Xlinker is used to pass options to the linker. “–Xlinker –Wl” is used to pass an option to the
system specific linker that gcc does not know. This is required when you want to link with the MPE namespace libraries
like NL, XL, LIBCPXL etc. Samba is required to be linked with LIBCPXL which can be done by specifying the option -
Xlinker –Wl,xl=/$HPACCOUNT/$HPGROUP/LIBCPXL to gcc compiler; where $HPACCOUNT is the shell variable
referring to the account you have logged in, $HPGROUP is again a shell variable refers to the current working group. That
is if you logged in as MGR.SAMBA, SMB3022 the $HPACCOUNT refers to SAMBA and $HPGROUP refers to SMB3022.
The MPE/iX linker LINKEDIT will be invoked to link with LIBCPXL. Refer to the manpage of gcc for more details on
–Xlinker. The libraries linked this way must be available during runtime at the same location from where it has been
linked. Hence, such type of libraries must be packaged along with the application for distribution. For Samba we package
and distribute LIBCPXL along with the Samba patch.
The discussion about header files and libraries will be helpful in configuring the compilation flags and switches to properly
include header files and properly use libraries to achieve a successful and error free build of the application under port.
Please refer
porting section on how the compilation flags and switches are set for Samba porting.
Next, we will discuss a few major MPE/iX limitations and issues we encountered while porting Samba-3.0.22 and strategy
to overcome them.
MPE/iX limitations and Major issues
This section discusses the major MPE/iX issues and limitations which a porter needs to be aware. Having cognizant about
the limitations and issues saves porter’s effort to debug the problem during compilation and also at runtime. We have
discussed following major limitations and issues:
UID and GID: MPE/iX’s POSIX implementation of UIDs and GIDs is incomplete in the sense that it lacks the
UID=0. In UNIX environment the superuser (root) has UID zero. The Unix root concept is roughly analogous to the
MPE concept of SM capability and/or PM capability. Many (almost all) portable UNIX applications sometimes set
their effective UID to zero in order to perform some privileged operations. Samba is not an exception and hence
the UID=0 has been simulated in lib/replace.c. Lars Appel simulated following routines which are widely used in
Samba to get and set uids and gids:
gid_t getegid(void);
uid_t geteuid(void);
gid_t getgid(void);
uid_t getuid(void);