The information in this section is especially useful for engineers who are at the porting stage of fixing compiler errors. The information here will help you to correct most of the compiler errors that you will encounter when doing a port, errors that will be related to system API incompatibilities. And, for those APIs that are compatible, as far as function calling, you will be able to recognize ERRNO incompatibilities and correct them early in the porting cycle.
Since its inception, UNIX has provided services to manipulate files and streams. Over the years, these services have become standard and are part of the operating system low-level I/O services. These services provide a rich set of APIs that can send data to or from either devices or files. Although these APIs are considered standard among all UNIX systems, including AIX and Linux, some information they return is not (for instance, ERRNOs).
Table 5-6. AIX and Linux System API Comparison: I/O Services
AIX | Linux | ERRNO(s) in AIX Not Implemented in Linux | Description |
---|
access accessx faccessx | access | ESTALE ETIMEDOUT | Check user's permissions for a file. |
fclear fclear64 | None | | Clear space in a file. |
fseek ftell rewind fgetpos fsetpos | fseek ftell rewind fgetpos fsetpos | EAGIN EFBIG EINTR EIO ENOSPC | Reposition a stream. |
fputc fputs putc putchar puts | fputc fputs putc putchar puts | EPIPE ENOMEM EOVERFLOW ESPIPE | Output character and strings. |
scanf fscanf sscanf | scanf fscanf sscanf | EAGIN EBADF EINTR EIO EINVAL EILSEQ ENOMEM | Input format conversion. |
fysnc | fysnc | EINVAL EINTR | Synchronize a file's complete in-core state with that on disk. |
getutent setutent enutent utmptname getutid getutid_r getutline_r pututline_r setutent_r endutent_r utmpname_r | getutent getutent_r getutid getutid_r gututline gututline_r putuline setutent endutent utmpname | None | Provides access user accounting database entries. Entries in database are described by the definitions and data structures in <utmp.h>. |
lseek lseek64 llseek | lseek llseek lseek64 | EOVERFLOW | Move the read-write pointer to within an open file. |
lockfx lockf flock | lockf flock fcntl | | Controls open file descriptors. |
open openx creat | open creat | EAGAIN EDQUOT EFBIG EINTR EIO ENOSR EOVERFLOW ESTALE | The open() system call is used to convert a path name into a file descriptor (a small, nonnegative integer for use in subsequent I/O as with read, write, and so on). When the call is successful, the file descriptor returned is the lowest file descriptor not currently open for the process. This call creates a new open file, not shared with any other process. (But shared open files may arise via the fork system call.) The new file descriptor is set to remain open across exec functions (see fcntl). The file offset is set to the beginning of the file. |
pathconf fpathconf | pathconf fpathconf | ESTALE ETIMEDOUT | Retrieve file-implementation characteristics. |
read readx readv readvx | read readv | EBADMSG EDEADLK EOVERFLOW ENXIO ESPIPE ETIMEDOUT | Read from a file descriptor. |
rename | rename | EDQUOT ETIMEDOUT ETXTBSY ESTALE | Change the name or location of a file. |
statx stat fstatx fstat fullstat | stat fstat lstat | ESTALE ETIMEDOUT EIO | Get file status. |
truncate ftruncate truncate64 ftruncate64 | truncate ftruncate truncate64 ftruncate64 | EAGAIN EDQUOT EFBIG EINTR EMFILE ENOSPC ESTALE ETIMEDOUT | Truncate a file to a specified length. |
unmask | unmask | | Set file creation mask. |
utimes utime | utimes utime | EPERM EACCES EROFS | Change access and/or modification times of an inode. |
write writex writev writevx | write, writev | EDQUOT ENXIO EFBIG ERANGE ESPIPE | Write to a file descriptor. |
chdir | chdir fchdir | ESTALE ETIMEDOUT | Change working directory. |
chroot | chroot | ESTALE ETIMEDOUT | Change root directory. |
getwd getcwd | get_current_dir_name getwd getcwd | ENOMEM | Get current working directory. |
glob globfree | glob globfree | | Find path names matching a pattern, free memory from glob(). |
link | link | EDQUOT ENOSPC ESTALE | Make a new name for a file. |
mkdir | mkdir | EDQUOT ETIMEOUT ESTALE | Create a directory. |
readdir readdir_r | readdir _syscall3 | | Return current location in directory stream. |
printf fprintf sprintf snprintf vprintf vfprintf vsprintf vsnprintf | printf fprintf sprintf snprintf vprintf vfprintf vsprintf vsnprintf | EAGAIN EABDF EFBIG EINTR EIO ENOSPC EPIPE ELSEQ EINVAL ENOMEM ENXIO | Format output conversion. |
rmdir | rmdir | EEXIST EINVAL ETIMEDOUT ESTALE | Remove a directory. |
scandir alphasort | scandir alphasor versionsort | | Scan a directory for matching entries. |
readlink | readlink | ERANGE ETIMEDOUT | Read value of a symbolic link. |
remove | romove | EBUSY ETIMEDOUT ESTALE EEXIST EINVAL | Delete a name and possibly the file it refers to. |
symlink | symlink | EDQUOT ETIMEDOUT ESTALE | Make a new name for a file. |
unlink | unlink | EBUSY ETIMEDOUT ESTALE | Deletes a name from the file system. If that name was the last link to a file and no processes have the file open, the file is deleted and the space it was using is made available for reuse. |
fscnt1 | None | | Manipulate filesystem control operations. |
getfsent_r getfsspec_r getfsfile_r getfstype_r setfsent_r endfsent_r | getfsent getfsspec getfsfile setfsent endfsent | | Gets information about a file system. (In AIX, _r denotes REENTRANT, which means functions are thread-safe. In Linux, you must make your modules that are using the equivalent APIs thread-safe.) |
getvfsent getvfsbytype getvfsbyname getvfsbyflag setvfsent | None | | Get a (Virtual File System) vfs file entry. |
mnct1 | None | | Return mount status information. |
quotac1 | quotac1 | ELOOP ENAMETOOLONG ENOENT EOPNOTSUPP EROFS EUSERS | Manipulate disk quotas. |
statfs fstatfs | statfs fstatfs | ESTALE ETIMEDOUT EIO | Get filesystem statistics. |
sysconf | sysconf | | Provide a way for the application to determine values for system limits or options at runtime. Functions are compatible, but the information they return is specific to the platform they are running on. |
sync | sync | | Functions are not compatible. In Linux, sync returns an int, and in AIX this function returns void. Causes all information in memory that should be on disk to be written out. The information returned and its format are different. |
unmak | unmask | | Set the umask to mask & 0777. |
vmount uvmount | None | | AIX-specific; creates what is known as a virtual filesystem (VFS). uvmount removes a VFS. umount can also be used as an alternative to uvmount. |
umount | umount | In AIX, ENOBLK is returned. In Linux, ENOTBLK is returned. | Unmount a previously mounted filesystem, directory, or file. |
close | close | ETIMEDOUT | Closes a file descriptor that has been previously opened by the open() call. |
chmod | chmod | ESTALE ETIMEDOUT | Used to change permissions of a file. |
chown fchown lchown | chown fchown lchown | EDQUOT EINVAL ESTALE | Used to change ownership of a file |
setregid setregid | setregid setregid | EINVAL | Sets real and/or effective user ID. |
Only pertinent Linux I/O services APIs relating to porting from AIX to Linux are mentioned in this section. You should investigate other API options that Linux has to offer. Table 5-6 should only serve as a guide for you to be able to recognize and identify API differences (in this case, I/O services APIs and their ERRNO return values) between Linux and AIX.