Samba 3.0.22 Porting by Vidya Sagar

29
If the compile error is related to something that an autoconfigure script checked for, verify that the script came up
with the correct answer and that the source code actually relies on this answer to determine what to do. We did
not encounter this error, hopefully you won’t either.
Many socket applications use PF_INET and other PF_xxx macros instead of AF_INET and corresponding macros
on MPE. The simplest way to deal with this is to modify your application’s source code to do:
#define PF_INET AF_INET
4.3 Common Run-Time Problems
Bytestream vs. MPE Fixed ASCII
Just like you should always use bytestream files to avoid compiler problems, you should also use bytestream files
to avoid run-time problems with your own application. An application that calls stat() to determine the EOF of an
MPE fixed ASCII file will get a value greater than the number of bytes the application would sequentially read from
the file due to the way the MPE bytestream emulator does not present trailing spaces to POSIX applications read
from such files.
fcntl() vs sfcntl()
MPE has two different versions of the POSIX fcntl() function -- one named sfcntl() that you must use on sockets,
and the traditional one named fcntl() that you use on all other file types. Sometimes it may be easiest to examine
an application and look for fcntl() calls that apply only to sockets and then replace those calls with sfcntl(). But at
other times, the same fcntl() call may be in a general purpose function that could operate both on sockets and
regular files. Therefore a run-time method is required to determine whether to call fcntl() or sfcntl(). The Porting
Wrappers has a solution for this problem -- see /POSIXC60/posix.1_defects/fcntl/fcntl.c for details. Section [2.1.4]
discusses
how to install porting wrappers and Appendix H contains the list of files.
Unresolved Externals
Nearly every porting attempt will experience multiple unresolved external references the first time the application
is run after a clean compile. Your first step in troubleshooting these errors is to verify that you are linking with the
correct *.a archive libraries (NMRLs) and/or *.sl (or *.so) shared libraries (NMXLs). The standard POSIX-related
libraries on MPE reside in /lib and /usr/lib. If you need to link with one of these system libraries, specify it via the -l
option of ld (note that gcc will pass-through linker options to ld if you are using gcc to link).
If the unresolved symbols are not part of the standard POSIX or sockets APIs, then you may need to link with a
non-system library. Specify a library path via the ld -L option. Subsequent -l options will then search the
preceding -L directories looking for the library. Set LDFLAGS and LIBS switches as discussed in section
adjusting
and running configure [3.5].
Socket Binding
Note that when doing socket programming, you must call GETPRIVMODE() before calling bind() to ports less
than 1024. Something else to be aware of with bind() is that you can only bind to the wildcard address (0.0.0.0,
meaning all network interfaces) or the loopback address (127.0.0.1) on MPE. Binding to a specific non-wildcard,
non-loopback address will fail. The general workaround here is to bind to the 0.0.0.0 wildcard address instead.
But note that this will listen on ALL network interfaces, so if an e3000 has multiple network interfaces, this
behavior could in theory be problematic if you did not really want the application to listen on certain network
interfaces.
Uninitialized struct passwd Fields
The POSIX getpwxxx() functions do not initialize the /usr/include/pwd.h fields labeled as “the following fields are
uninitialized until further notice”. That means the char * fields will contain garbage for the pointer addresses, so if
you attempt to dereference these fields, your program will either abort or retrieve random data.
Streams/iX (pipes) Hangs
POSIX pipes are implemented via Streams/iX. Over the years Streams/iX has had a number of bugs that can
result in system crashes or application hangs for programs that use POSIX pipes. Streams/iX hangs will be