aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/aix/linux
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/aix/linux')
-rw-r--r--sysdeps/unix/sysv/aix/linux/errnoconv.c125
-rw-r--r--sysdeps/unix/sysv/aix/linux/linux-errno.h135
-rw-r--r--sysdeps/unix/sysv/aix/linux/linux-stat.h131
-rw-r--r--sysdeps/unix/sysv/aix/linux/statconv.c35
4 files changed, 426 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/aix/linux/errnoconv.c b/sysdeps/unix/sysv/aix/linux/errnoconv.c
new file mode 100644
index 0000000000..95bd5a32b2
--- /dev/null
+++ b/sysdeps/unix/sysv/aix/linux/errnoconv.c
@@ -0,0 +1,125 @@
+/* Convert the error number the AIX kernel returns to what the Linux
+ application expects. */
+#include <errno.h>
+#include "linux-errno.h"
+
+
+static int mapping[] =
+{
+ [EPERM] = LINUX_EPERM,
+ [ENOENT] = LINUX_ENOENT,
+ [ESRCH] = LINUX_ESRCH,
+ [EINTR] = LINUX_EINTR,
+ [EIO] = LINUX_EIO,
+ [ENXIO] = LINUX_ENXIO,
+ [E2BIG] = LINUX_E2BIG,
+ [ENOEXEC] = LINUX_ENOEXEC,
+ [EBADF] = LINUX_EBADF,
+ [ECHILD] = LINUX_ECHILD,
+ [EAGAIN] = LINUX_EAGAIN,
+ [ENOMEM] = LINUX_ENOMEM,
+ [EACCES] = LINUX_EACCES,
+ [EFAULT] = LINUX_EFAULT,
+ [ENOTBLK] = LINUX_ENOTBLK,
+ [EBUSY] = LINUX_EBUSY,
+ [EEXIST] = LINUX_EEXIST,
+ [EXDEV] = LINUX_EXDEV,
+ [ENODEV] = LINUX_ENODEV,
+ [ENOTDIR] = LINUX_ENOTDIR,
+ [EISDIR] = LINUX_EISDIR,
+ [EINVAL] = LINUX_EINVAL,
+ [ENFILE] = LINUX_ENFILE,
+ [EMFILE] = LINUX_EMFILE,
+ [ENOTTY] = LINUX_ENOTTY,
+ [ETXTBSY] = LINUX_ETXTBSY,
+ [EFBIG] = LINUX_EFBIG,
+ [ENOSPC] = LINUX_ENOSPC,
+ [EIDRM] = LINUX_EIDRM,
+ [ECHRNG] = LINUX_ECHRNG,
+ [EL2NSYNC] = LINUX_EL2NSYNC,
+ [EL3HLT] = LINUX_EL3HLT,
+ [EL3RST] = LINUX_EL3RST,
+ [ELNRNG] = LINUX_ELNRNG,
+ [EUNATCH] = LINUX_EUNATCH,
+ [ENOCSI] = LINUX_ENOCSI,
+ [EL2HLT] = LINUX_EL2HLT,
+ [EDEADLK] = LINUX_EDEADLK,
+ [ENOTREADY] = LINUX_ENOTREADY,
+ // EWPROTECT: no Linux equivalent
+ // EFORMAT: no Linux equivalent
+ [ENOLCK] = LINUX_ENOLCK,
+ // ENOCONNECT: No Linux equivalent
+ [ESTALE] = LINUX_ESTALE,
+ // EDIST: no Linux equivalent
+ [54] = LINUX_EAGAIN, // EWOULDBLOCK
+ [EINPROGRESS] = LINUX_EINPROGRESS,
+ [EALREADY] = LINUX_EALREADY,
+ [ENOTSOCK] = LINUX_ENOTSOCK,
+ [EDESTADDRREQ] = LINUX_EDESTADDRREQ,
+ [EMSGSIZE] = LINUX_EMSGSIZE,
+ [EPROTOTYPE] = LINUX_EPROTOTYPE,
+ [ENOPROTOOPT] = LINUX_ENOPROTOOPT,
+ [EPROTONOSUPPORT] = LINUX_EPROTONOSUPPORT,
+ [ESOCKTNOSUPPORT] = LINUX_ESOCKTNOSUPPORT,
+ [EOPNOTSUPP] = LINUX_EOPNOTSUPP,
+ [EPFNOSUPPORT] = LINUX_EPFNOSUPPORT,
+ [EAFNOSUPPORT] = LINUX_EAFNOSUPPORT,
+ [EADDRINUSE] = LINUX_EADDRINUSE,
+ [EADDRNOTAVAIL] = LINUX_EADDRNOTAVAIL,
+ [ENETDOWN] = LINUX_ENETDOWN,
+ [ENETUNREACH] = LINUX_ENETUNREACH,
+ [ENETRESET] = LINUX_ENETRESET,
+ [ECONNABORTED] = LINUX_ECONNABORTED,
+ [ECONNRESET] = LINUX_ECONNRESET,
+ [ENOBUFS] = LINUX_ENOBUFS,
+ [EISCONN] = LINUX_EISCONN,
+ [ENOTCONN] = LINUX_ENOTCONN,
+ [ESHUTDOWN] = LINUX_ESHUTDOWN,
+ [ETIMEDOUT] = LINUX_ETIMEDOUT,
+ [ECONNREFUSED] = LINUX_ECONNREFUSED,
+ [EHOSTDOWN] = LINUX_EHOSTDOWN,
+ [EHOSTUNREACH] = LINUX_EHOSTUNREACH,
+ [ERESTART] = LINUX_ERESTART,
+ [EPROCLIM] = LINUX_EPROCLIM,
+ [EUSERS] = LINUX_EUSERS,
+ [ELOOP] = LINUX_ELOOP,
+ [ENAMETOOLONG] = LINUX_ENAMETOOLONG,
+ [87] = LINUX_ENOTEMPTY, // ENOTEMPTY
+ [EDQUOT] = LINUX_EDQUOT,
+ [ECORRUPT] = LINUX_ECORRUPT,
+ [EREMOTE] = LINUX_EREMOTE,
+ [ENOSYS] = LINUX_ENOSYS,
+ [EMEDIA] = LINUX_EMEDIA,
+ [ESOFT] = LINUX_ESOFT,
+ [ENOATTR] = LINUX_ENOATTR,
+ [ESAD] = LINUX_ESAD,
+ // ENOTRUST: no Linux equivalent
+ [ETOOMANYREFS] = LINUX_ETOOMANYREFS,
+ [EILSEQ] = LINUX_EILSEQ,
+ [ECANCELED] = LINUX_ECANCELED,
+ [ENOSR] = LINUX_ENOSR,
+ [ETIME] = LINUX_ETIME,
+ [EBADMSG] = LINUX_EBADMSG,
+ [EPROTO] = LINUX_EPROTO,
+ [ENODATA] = LINUX_ENODATA,
+ [ENOSTR] = LINUX_ENOSTR,
+ [ENOTSUP] = LINUX_ENOTSUP,
+ [EMULTIHOP] = LINUX_EMULTIHOP,
+ [ENOLINK] = LINUX_ENOLINK,
+ [EOVERFLOW] = LINUX_EOVERFLOW
+};
+
+
+int
+__errno_aix_to_linux (int err)
+{
+ int conv;
+
+ if (err >= 0 && err < (sizeof (mapping) / sizeof (mapping[0]))
+ && ((conv = mapping[err]) != 0 || err == 0))
+ return conv;
+
+ /* The error value is not known. Create a special value which can
+ be easily recognized as an invalid result. */
+ return 512 + err;
+}
diff --git a/sysdeps/unix/sysv/aix/linux/linux-errno.h b/sysdeps/unix/sysv/aix/linux/linux-errno.h
new file mode 100644
index 0000000000..b7cf0a5c5f
--- /dev/null
+++ b/sysdeps/unix/sysv/aix/linux/linux-errno.h
@@ -0,0 +1,135 @@
+#ifndef _LINUX_ERRNO_H
+#define _LINUX_ERRNO_H
+
+#define LINUX_EPERM 1
+#define LINUX_ENOENT 2
+#define LINUX_ESRCH 3
+#define LINUX_EINTR 4
+#define LINUX_EIO 5
+#define LINUX_ENXIO 6
+#define LINUX_E2BIG 7
+#define LINUX_ENOEXEC 8
+#define LINUX_EBADF 9
+#define LINUX_ECHILD 10
+#define LINUX_EAGAIN 11
+#define LINUX_ENOMEM 12
+#define LINUX_EACCES 13
+#define LINUX_EFAULT 14
+#define LINUX_ENOTBLK 15
+#define LINUX_EBUSY 16
+#define LINUX_EEXIST 17
+#define LINUX_EXDEV 18
+#define LINUX_ENODEV 19
+#define LINUX_ENOTDIR 20
+#define LINUX_EISDIR 21
+#define LINUX_EINVAL 22
+#define LINUX_ENFILE 23
+#define LINUX_EMFILE 24
+#define LINUX_ENOTTY 25
+#define LINUX_ETXTBSY 26
+#define LINUX_EFBIG 27
+#define LINUX_ENOSPC 28
+#define LINUX_ESPIPE 29
+#define LINUX_EROFS 30
+#define LINUX_EMLINK 31
+#define LINUX_EPIPE 32
+#define LINUX_EDOM 33
+#define LINUX_ERANGE 34
+#define LINUX_EDEADLK 35
+#define LINUX_ENAMETOOLONG 36
+#define LINUX_ENOLCK 37
+#define LINUX_ENOSYS 38
+#define LINUX_ENOTEMPTY 39
+#define LINUX_ELOOP 40
+#define LINUX_ENOMSG 42
+#define LINUX_EIDRM 43
+#define LINUX_ECHRNG 44
+#define LINUX_EL2NSYNC 45
+#define LINUX_EL3HLT 46
+#define LINUX_EL3RST 47
+#define LINUX_ELNRNG 48
+#define LINUX_EUNATCH 49
+#define LINUX_ENOCSI 50
+#define LINUX_EL2HLT 51
+#define LINUX_EBADE 52
+#define LINUX_EBADR 53
+#define LINUX_EXFULL 54
+#define LINUX_ENOANO 55
+#define LINUX_EBADRQC 56
+#define LINUX_EBADSLT 57
+#define LINUX_EDEADLOCK 58
+#define LINUX_EBFONT 59
+#define LINUX_ENOSTR 60
+#define LINUX_ENODATA 61
+#define LINUX_ETIME 62
+#define LINUX_ENOSR 63
+#define LINUX_ENONET 64
+#define LINUX_ENOPKG 65
+#define LINUX_EREMOTE 66
+#define LINUX_ENOLINK 67
+#define LINUX_EADV 68
+#define LINUX_ESRMNT 69
+#define LINUX_ECOMM 70
+#define LINUX_EPROTO 71
+#define LINUX_EMULTIHOP 72
+#define LINUX_EDOTDOT 73
+#define LINUX_EBADMSG 74
+#define LINUX_EOVERFLOW 75
+#define LINUX_ENOTUNIQ 76
+#define LINUX_EBADFD 77
+#define LINUX_EREMCHG 78
+#define LINUX_ELIBACC 79
+#define LINUX_ELIBBAD 80
+#define LINUX_ELIBSCN 81
+#define LINUX_ELIBMAX 82
+#define LINUX_ELIBEXEC 83
+#define LINUX_EILSEQ 84
+#define LINUX_ERESTART 85
+#define LINUX_ESTRPIPE 86
+#define LINUX_EUSERS 87
+#define LINUX_ENOTSOCK 88
+#define LINUX_EDESTADDRREQ 89
+#define LINUX_EMSGSIZE 90
+#define LINUX_EPROTOTYPE 91
+#define LINUX_ENOPROTOOPT 92
+#define LINUX_EPROTONOSUPPORT 93
+#define LINUX_ESOCKTNOSUPPORT 94
+#define LINUX_EOPNOTSUPP 95
+#define LINUX_EPFNOSUPPORT 96
+#define LINUX_EAFNOSUPPORT 97
+#define LINUX_EADDRINUSE 98
+#define LINUX_EADDRNOTAVAIL 99
+#define LINUX_ENETDOWN 100
+#define LINUX_ENETUNREACH 101
+#define LINUX_ENETRESET 102
+#define LINUX_ECONNABORTED 103
+#define LINUX_ECONNRESET 104
+#define LINUX_ENOBUFS 105
+#define LINUX_EISCONN 106
+#define LINUX_ENOTCONN 107
+#define LINUX_ESHUTDOWN 108
+#define LINUX_ETOOMANYREFS 109
+#define LINUX_ETIMEDOUT 110
+#define LINUX_ECONNREFUSED 111
+#define LINUX_EHOSTDOWN 112
+#define LINUX_EHOSTUNREACH 113
+#define LINUX_EALREADY 114
+#define LINUX_EINPROGRESS 115
+#define LINUX_ESTALE 116
+#define LINUX_EUCLEAN 117
+#define LINUX_ENOTNAM 118
+#define LINUX_ENAVAIL 119
+#define LINUX_EISNAM 120
+#define LINUX_EREMOTEIO 121
+#define LINUX_EDQUOT 122
+
+#define LINUX_ENOMEDIUM 123
+#define LINUX_EMEDIUMTYPE 124
+
+/* Should never be seen by user programs */
+#define LINUX_ERESTARTSYS 512
+#define LINUX_ERESTARTNOINTR 513
+#define LINUX_ERESTARTNOHAND 514
+#define LINUX_ENOIOCTLCMD 515
+
+#endif
diff --git a/sysdeps/unix/sysv/aix/linux/linux-stat.h b/sysdeps/unix/sysv/aix/linux/linux-stat.h
new file mode 100644
index 0000000000..01a2d4d253
--- /dev/null
+++ b/sysdeps/unix/sysv/aix/linux/linux-stat.h
@@ -0,0 +1,131 @@
+/* Copyright (C) 1992, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+/* Versions of the `struct stat' data structure. */
+#define _STAT_VER_LINUX_OLD 1
+#define _STAT_VER_KERNEL 1
+#define _STAT_VER_SVR4 2
+#define _STAT_VER_LINUX 3
+#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
+
+/* Versions of the `xmknod' interface. */
+#define _MKNOD_VER_LINUX 1
+#define _MKNOD_VER_SVR4 2
+#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
+
+
+struct stat
+ {
+ __dev_t st_dev; /* Device. */
+ unsigned short int __pad1;
+#ifndef __USE_FILE_OFFSET64
+ __ino_t st_ino; /* File serial number. */
+#else
+ __ino64_t st_ino; /* File serial number. */
+#endif
+ __mode_t st_mode; /* File mode. */
+ __nlink_t st_nlink; /* Link count. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+#ifndef __USE_FILE_OFFSET64
+ __off_t st_size; /* Size of file, in bytes. */
+#else
+ __off64_t st_size; /* Size of file, in bytes. */
+#endif
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+
+#ifndef __USE_FILE_OFFSET64
+ __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
+#else
+ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+#endif
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int __unused1;
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int __unused2;
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int __unused3;
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+ };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+ {
+ __dev_t st_dev; /* Device. */
+ unsigned short int __pad1;
+
+ __ino64_t st_ino; /* File serial number. */
+ __mode_t st_mode; /* File mode. */
+ __nlink_t st_nlink; /* Link count. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+ __off64_t st_size; /* Size of file, in bytes. */
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+
+ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int __unused1;
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int __unused2;
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int __unused3;
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+ };
+#endif
+
+/* Tell code we have these members. */
+#define _STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+/* These don't actually exist on System V, but having them doesn't hurt. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+
+/* Thi macro (with a different name) is normally in <sys/sysmacros.h>. */
+#define linux_makedev(major, minor) (((major) << 8 | (minor)))
diff --git a/sysdeps/unix/sysv/aix/linux/statconv.c b/sysdeps/unix/sysv/aix/linux/statconv.c
new file mode 100644
index 0000000000..5333e23d7b
--- /dev/null
+++ b/sysdeps/unix/sysv/aix/linux/statconv.c
@@ -0,0 +1,35 @@
+void
+__stat_aix_to_linux (const struct stat *aixstat, struct stat *linuxstat)
+{
+ linuxstat->st_dev = linux_makedev (major (aixstat->st_dev),
+ minor (aixstat->st_dev));
+ linuxstat->st_ino = aixstat->st_ino;
+ /* The following assumes that the mode values are the same on AIX
+ and Linux which is true in the moment. */
+ linuxstat->st_mode = aixstat->st_mode;
+ linuxstat->st_nlink = aixstat->st_nlink;
+ /* There is no st_flag field in Linux. */
+ linuxstat->st_uid = aixstat->st_uid;
+ linuxstat->st_gid = aixstat->st_gid;
+ linuxstat->st_rdev = linux_makedev (major (aixstat->st_rdev),
+ minor (aixstat->st_rdev));
+ linuxstat->st_size = aixstat->st_size;
+ linuxstat->st_atime = aixstat->st_atime;
+ linuxstat->st_mtime = aixstat->st_mtime;
+ linuxstat->st_ctime = aixstat->st_ctime;
+ linuxstat->st_blksize = aixstat->st_blksize;
+ linuxstat->st_blocks = aixstat->st_blocks;
+ /* There is no st_vfstype in Linux. */
+ /* There is no st_vfs in Linux. */
+ /* There is no st_type in Linux. */
+ /* There is no st_gen in Linux. */
+
+ /* File in the padding values with repeatable values. */
+ linuxstat->__pad1 = 0;
+ linuxstat->__pad2 = 0;
+ linuxstat->__unused1 = 0;
+ linuxstat->__unused2 = 0;
+ linuxstat->__unused3 = 0;
+ linuxstat->__unused4 = 0;
+ linuxstat->__unused5 = 0;
+}