diff -Nur fileutils-3.13.org/config.h.os2 fileutils-3.13/config.h.os2 --- fileutils-3.13.org/config.h.os2 Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/config.h.os2 Tue Mar 31 06:46:36 1998 @@ -0,0 +1,409 @@ +/* config.h.in. Generated manually for emx+gcc under OS/2. */ + +#define OS2 +#define _POSIX_VERSION +#define chown(path, uid, gid) 0 + +/* Define if using alloca.c. */ +#undef C_ALLOCA + +/* Define if the closedir function returns void instead of int. */ +#undef CLOSEDIR_VOID + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +#undef CRAY_STACKSEG_END + +/* Define to the type of elements in the array set by `getgroups'. + Usually this is either `int' or `gid_t'. */ +#undef GETGROUPS_T + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have and it should be used (not on Ultrix). */ +#define HAVE_ALLOCA_H 1 + +/* Define if you don't have vprintf but do have _doprnt. */ +#undef HAVE_DOPRNT + +/* Define if you have the getmntent function. */ +#undef HAVE_GETMNTENT + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if your struct stat has st_blocks. */ +#undef HAVE_ST_BLOCKS + +/* Define if utime(file, NULL) sets file's timestamp to the present. */ +#define HAVE_UTIME_NULL 1 + +/* Define if you have the vprintf function. */ +#define HAVE_VPRINTF 1 + +/* Define as __inline if that's what the C compiler calls it. */ +#undef inline + +/* Define if major, minor, and makedev are declared in . */ +#undef MAJOR_IN_MKDEV + +/* Define if major, minor, and makedev are declared in . */ +#undef MAJOR_IN_SYSMACROS + +/* Define if on MINIX. */ +#undef _MINIX + +/* Define to `int' if doesn't define. */ +#undef mode_t + +/* Define to `long' if doesn't define. */ +#undef off_t + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +#undef _POSIX_1_SOURCE + +/* Define if you need to in order for stat and other things to work. */ +#undef _POSIX_SOURCE + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +#undef STACK_DIRECTION + +/* Define if the `S_IS*' macros in do not work properly. */ +#undef STAT_MACROS_BROKEN + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define if your declares struct tm. */ +#undef TM_IN_SYS_TIME + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define if you have the Andrew File System. */ +#undef AFS + +/* Define to 1 if NLS is requested. */ +#define ENABLE_NLS 1 + +/* Define if your system defines TIOCGWINSZ in sys/ioctl.h. */ +#undef GWINSZ_IN_SYS_IOCTL + +/* Define as 1 if you have catgets and don't want to use GNU gettext. */ +#undef HAVE_CATGETS + +/* Define as 1 if you have gettext and don't want to use GNU gettext. */ +#undef HAVE_GETTEXT + +/* Define if your locale.h file contains LC_MESSAGES. */ +#undef HAVE_LC_MESSAGES + +/* Define to 1 if you have the stpcpy function. */ +#undef HAVE_STPCPY + +/* Define to `unsigned long' if doesn't define. */ +#undef ino_t + +/* Define if there is a member named d_ino in the struct describing + directory headers. */ +#undef D_INO_IN_DIRENT + +/* Define if `struct utimbuf' is declared -- usually in . */ +#define HAVE_STRUCT_UTIMBUF 1 + +/* Define if there is no specific function for reading the list of + mounted filesystems. fread will be used to read /etc/mnttab. [SVR2] */ +#undef MOUNTED_FREAD + +/* Define if (like SVR2) there is no specific function for reading the + list of mounted filesystems, and your system has these header files: + and . [SVR3] */ +#undef MOUNTED_FREAD_FSTYP + +/* Define if there is a function named getfsstat for reading the list + of mounted filesystems. [DEC Alpha running OSF/1] */ +#undef MOUNTED_GETFSSTAT + +/* Define if there is a function named getmnt for reading the list of + mounted filesystems. [Ultrix] */ +#undef MOUNTED_GETMNT + +/* Define if there is a function named getmntent for reading the list + of mounted filesystems, and that function takes a single argument. + [4.3BSD, SunOS, HP-UX, Dynix, Irix] */ +#undef MOUNTED_GETMNTENT1 + +/* Define if there is a function named getmntent for reading the list of + mounted filesystems, and that function takes two arguments. [SVR4] */ +#undef MOUNTED_GETMNTENT2 + +/* Define if there is a function named getmntinfo for reading the list + of mounted filesystems. [4.4BSD] */ +#undef MOUNTED_GETMNTINFO + +/* Define if there is a function named listmntent that can be used to + list all mounted filesystems. [UNICOS] */ +#undef MOUNTED_LISTMNTENT + +/* Define if there is a function named mntctl that can be used to read + the list of mounted filesystems, and there is a system header file + that declares `struct vmount.' [AIX] */ +#undef MOUNTED_VMOUNT + +/* Define to the name of the distribution. */ +#define PACKAGE "fileutils" + +/* The concatenation of the strings PACKAGE, "-", and VERSION. */ +#define PACKAGE_VERSION "GNU file utilities 3.13" + +/* Define to 1 if ANSI function prototypes are usable. */ +#define PROTOTYPES 1 + +/* Define if statfs takes 3 args. [DEC Alpha running OSF/1] */ +#undef STAT_STATFS3_OSF1 + +/* Define if there is no specific function for reading filesystems usage + information and you have the header file. [SVR2] */ +#undef STAT_READ_FILSYS + +/* Define if statfs takes 2 args and struct statfs has a field named f_bsize. + [4.3BSD, SunOS 4, HP-UX, AIX PS/2] */ +#undef STAT_STATFS2_BSIZE + +/* Define if statfs takes 2 args and struct statfs has a field named f_fsize. + [4.4BSD, NetBSD] */ +#undef STAT_STATFS2_FSIZE + +/* Define if statfs takes 2 args and the second argument has + type struct fs_data. [Ultrix] */ +#undef STAT_STATFS2_FS_DATA + +/* Define if statfs takes 4 args. [SVR3, Dynix, Irix, Dolphin] */ +#undef STAT_STATFS4 + +/* Define if there is a function named statvfs. [SVR4] */ +#undef STAT_STATVFS + +/* Define if the block counts reported by statfs may be truncated to 2GB + and the correct values may be stored in the f_spare array. + [SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem. + SunOS 4.1.1 seems not to be affected.] */ +#undef STATFS_TRUNCATES_BLOCK_COUNTS + +/* Define to the version of the distribution. */ +#define VERSION "3.13" + +/* Define if you have the __argz_count function. */ +#undef HAVE___ARGZ_COUNT + +/* Define if you have the __argz_next function. */ +#undef HAVE___ARGZ_NEXT + +/* Define if you have the __argz_stringify function. */ +#undef HAVE___ARGZ_STRINGIFY + +/* Define if you have the bcopy function. */ +#define HAVE_BCOPY 1 + +/* Define if you have the dcgettext function. */ +#undef HAVE_DCGETTEXT + +/* Define if you have the endgrent function. */ +#undef HAVE_ENDGRENT + +/* Define if you have the endpwent function. */ +#undef HAVE_ENDPWENT + +/* Define if you have the fchdir function. */ +#undef HAVE_FCHDIR + +/* Define if you have the ftime function. */ +#define HAVE_FTIME 1 + +/* Define if you have the ftruncate function. */ +#define HAVE_FTRUNCATE 1 + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getgroups function. */ +#undef HAVE_GETGROUPS + +/* Define if you have the getmntinfo function. */ +#undef HAVE_GETMNTINFO + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the gettimeofday function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define if you have the isascii function. */ +#define HAVE_ISASCII 1 + +/* Define if you have the lchown function. */ +#undef HAVE_LCHOWN + +/* Define if you have the listmntent function. */ +#undef HAVE_LISTMNTENT + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the mkfifo function. */ +#undef HAVE_MKFIFO + +/* Define if you have the munmap function. */ +#undef HAVE_MUNMAP + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the setenv function. */ +#undef HAVE_SETENV + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE + +/* Define if you have the statvfs function. */ +#undef HAVE_STATVFS + +/* Define if you have the stpcpy function. */ +#undef HAVE_STPCPY + +/* Define if you have the strcasecmp function. */ +#undef HAVE_STRCASECMP + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the strerror function. */ +#define HAVE_STRERROR 1 + +/* Define if you have the strrchr function. */ +#define HAVE_STRRCHR 1 + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. */ +#undef HAVE_ARGZ_H + +/* Define if you have the header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define if you have the header file. */ +#undef HAVE_MNTENT_H + +/* Define if you have the header file. */ +#undef HAVE_MNTTAB_H + +/* Define if you have the header file. */ +#undef HAVE_NDIR_H + +/* Define if you have the header file. */ +#undef HAVE_NL_TYPES_H + +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_FILSYS_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_FS_TYPES_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_FSTYP_H + +/* Define if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_MOUNT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_STATFS_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STATVFS_H + +/* Define if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_VFS_H + +/* Define if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define if you have the header file. */ +#undef HAVE_VALUES_H + +/* Define if you have the bsd library (-lbsd). */ +#undef HAVE_LIBBSD + +/* Define if you have the i library (-li). */ +#undef HAVE_LIBI + +/* Define if you have the intl library (-lintl). */ +#undef HAVE_LIBINTL + +/* Define if you have the ldgc library (-lldgc). */ +#undef HAVE_LIBLDGC + +/* Define if you have the ypsec library (-lypsec). */ +#undef HAVE_LIBYPSEC diff -Nur fileutils-3.13.org/intl/libgettext.h fileutils-3.13/intl/libgettext.h --- fileutils-3.13.org/intl/libgettext.h Sun Jun 16 18:50:30 1996 +++ fileutils-3.13/intl/libgettext.h Wed Aug 7 18:20:40 1996 @@ -36,6 +36,14 @@ # include #endif +#ifdef OS2 +#define CheckEnv(e, d) ({char *v = getenv(e); v ? v : (d);}) +#define StrCat(s1, s2) ({int l = strlen(s1) + strlen(s2); \ + char *r = malloc(l); strcpy(r, s1); strcat(r, s2); r;}) +#define GNULOCALEDIR CheckEnv("GNULOCALEDIR","/lib/glocale") +#define LOCALE_ALIAS_PATH StrCat(GNULOCALEDIR, ";.") +#define LOCALEDIR CheckEnv("LOCALEDIR","/lib/locale") +#endif #ifdef __cplusplus extern "C" { diff -Nur fileutils-3.13.org/lib/basename.c fileutils-3.13/lib/basename.c --- fileutils-3.13.org/lib/basename.c Sat Apr 20 04:32:18 1996 +++ fileutils-3.13/lib/basename.c Fri Aug 2 08:33:02 1996 @@ -30,7 +30,11 @@ while (*name) { +#ifdef OS2 + if (*name == '/' || *name == '\\' || *name == ':') +#else if (*name == '/') +#endif base = name + 1; ++name; } diff -Nur fileutils-3.13.org/lib/diskacc2.c fileutils-3.13/lib/diskacc2.c --- fileutils-3.13.org/lib/diskacc2.c Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/lib/diskacc2.c Thu Mar 16 17:29:50 1995 @@ -0,0 +1,211 @@ +/* diskacc2.c - direct disk access library for OS/2 2.x protected mode. + * + * Author: Kai Uwe Rommel + * Created: Fri Jul 08 1994 + */ + +static char *rcsid = +"$Id: diskacc2.c,v 1.1 1994/07/08 21:34:12 rommel Exp rommel $"; +static char *rcsrev = "$Revision: 1.1 $"; + +/* + * $Log: diskacc2.c,v $ + * Revision 1.1 1994/07/08 21:34:12 rommel + * Initial revision + * + */ + +#define INCL_DOSDEVICES +#define INCL_DOSDEVIOCTL +#define INCL_NOPM +#include +#include +#include + +#include "diskacc2.h" + +#define PHYSICAL 0x1000 +#define CATEGORY(x) (((x) & PHYSICAL) ? IOCTL_PHYSICALDISK : IOCTL_DISK) +#define HANDLE(x) ((x) & ~PHYSICAL) + +#pragma pack(1) + +typedef struct +{ + BYTE bCommand; + USHORT usHead; + USHORT usCylinder; + USHORT usFirstSector; + USHORT cSectors; + struct + { + USHORT usSectorNumber; + USHORT usSectorSize; + } + TrackTable[64]; +} +TRACK; + +ULONG DosDevIOCtl32(PVOID pData, ULONG cbData, PVOID pParms, ULONG cbParms, + ULONG usFunction, HFILE hDevice) +{ + ULONG ulParmLengthInOut = cbParms, ulDataLengthInOut = cbData; + return DosDevIOCtl(HANDLE(hDevice), CATEGORY(hDevice), usFunction, + pParms, cbParms, &ulParmLengthInOut, + pData, cbData, &ulDataLengthInOut); +} + +static int test_sector(int handle, int side, int track, int sector) +{ + char buffer[1024]; + TRACK trk; + + trk.bCommand = 0; + trk.usHead = side; + trk.usCylinder = track; + trk.usFirstSector = 0; + trk.cSectors = 1; + + trk.TrackTable[0].usSectorNumber = sector; + trk.TrackTable[0].usSectorSize = 512; + + return DosDevIOCtl32(buffer, sizeof(buffer), &trk, sizeof(trk), + DSK_READTRACK, handle) == 0; +} + +int DskOpen(char *drv, int logical, int lock, + unsigned *sides, unsigned *tracks, unsigned *sectors) +{ + BIOSPARAMETERBLOCK bpb; + DEVICEPARAMETERBLOCK dpb; + HFILE handle; + USHORT physical; + ULONG action; + BYTE cmd = logical; + + if (isalpha(drv[0]) && drv[1] == ':' && drv[2] == 0) + { + if (DosOpen(drv, &handle, &action, 0L, FILE_NORMAL, FILE_OPEN, + OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR | + OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE, 0L)) + return -1; + } + else if (drv[0] == '$' && isdigit(drv[1]) && drv[2] == ':' && drv[3] == 0) + { + if (DosPhysicalDisk(INFO_GETIOCTLHANDLE, &physical, sizeof(physical), + drv + 1, strlen(drv + 1) + 1)) + return -1; + handle = physical | PHYSICAL; + } + else + return -1; + + if (handle & PHYSICAL) + { + if (DosDevIOCtl32(&dpb, sizeof(dpb), &cmd, sizeof(cmd), + DSK_GETDEVICEPARAMS, handle)) + { + DosPhysicalDisk(INFO_FREEIOCTLHANDLE, NULL, 0, &physical, sizeof(physical)); + return -1; + } + + *sectors = dpb.cSectorsPerTrack; + *tracks = dpb.cCylinders; + *sides = dpb.cHeads; + } + else + { + if (DosDevIOCtl32(&bpb, sizeof(bpb), &cmd, sizeof(cmd), + DSK_GETDEVICEPARAMS, handle)) + { + DosClose(handle); + return -1; + } + + *sectors = bpb.usSectorsPerTrack; + *tracks = bpb.cCylinders; + *sides = bpb.cHeads; + } + + + if (lock && DosDevIOCtl32(0L, 0, &cmd, sizeof(cmd), DSK_LOCKDRIVE, handle)) + { + if (handle & PHYSICAL) + DosPhysicalDisk(INFO_FREEIOCTLHANDLE, NULL, 0, &physical, sizeof(physical)); + else + DosClose(handle); + return -1; + } + + if (*sectors >= 15) /* 360k floppies ... */ + if (!test_sector(handle, 0, 0, 15)) + { + if (*sectors == 15) + *tracks = 40; + + *sectors = 9; + } + + return handle; +} + +int DskClose(int handle) +{ + BYTE cmd = 0; + USHORT physical = handle & ~PHYSICAL; + + DosDevIOCtl32(0L, 0, &cmd, sizeof(cmd), DSK_UNLOCKDRIVE, handle); + + if (handle & PHYSICAL) + return DosPhysicalDisk(INFO_FREEIOCTLHANDLE, NULL, 0, + &physical, sizeof(physical)); + else + return DosClose(handle); +} + +int DskRead(int handle, unsigned side, unsigned track, + unsigned sector, unsigned nsects, void *buf) +{ + TRACK trk; + unsigned cnt; + + trk.bCommand = 0; + trk.usHead = side; + trk.usCylinder = track; + trk.usFirstSector = 0; + trk.cSectors = nsects; + + for (cnt = 0; cnt < nsects; cnt++) + { + trk.TrackTable[cnt].usSectorNumber = sector + cnt; + trk.TrackTable[cnt].usSectorSize = 512; + } + + return DosDevIOCtl32(buf, nsects * 512, &trk, sizeof(trk), + DSK_READTRACK, handle); +} + +int DskWrite(int handle, unsigned side, unsigned track, + unsigned sector, unsigned nsects, void *buf) +{ + TRACK trk; + unsigned cnt; + + trk.bCommand = 0; + trk.usHead = side; + trk.usCylinder = track; + trk.usFirstSector = 0; + trk.cSectors = nsects; + + for (cnt = 0; cnt < nsects; cnt++) + { + trk.TrackTable[cnt].usSectorNumber = sector + cnt; + trk.TrackTable[cnt].usSectorSize = 512; + } + + return DosDevIOCtl32(buf, nsects * 512, &trk, sizeof(trk), + DSK_WRITETRACK, handle); +} + + +/* end of diskacc2.c */ diff -Nur fileutils-3.13.org/lib/diskacc2.h fileutils-3.13/lib/diskacc2.h --- fileutils-3.13.org/lib/diskacc2.h Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/lib/diskacc2.h Thu Mar 16 17:27:36 1995 @@ -0,0 +1,27 @@ +/* diskacc2.h - direct disk access library for OS/2 2.x protected mode. + * + * Author: Kai Uwe Rommel + * Created: Fri Jul 08 1994 + */ + +/* $Id: diskacc2.h,v 1.2 1994/07/08 21:35:50 rommel Exp rommel $ */ + +/* + * $Log: diskacc2.h,v $ + * Revision 1.2 1994/07/08 21:35:50 rommel + * bug fix + * + * Revision 1.1 1994/07/08 21:34:12 rommel + * Initial revision + * + */ + +int DskOpen(char *drv, int logical, int lock, + unsigned *sides, unsigned *tracks, unsigned *sectors); +int DskClose(int handle); +int DskRead(int handle, unsigned side, unsigned track, + unsigned sector, unsigned nsects, void *buf); +int DskWrite(int handle, unsigned side, unsigned track, + unsigned sector, unsigned nsects, void *buf); + +/* end of diskacc2.h */ diff -Nur fileutils-3.13.org/lib/disktape.c fileutils-3.13/lib/disktape.c --- fileutils-3.13.org/lib/disktape.c Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/lib/disktape.c Thu Mar 16 17:27:08 1995 @@ -0,0 +1,246 @@ +/* DISKTAPE.C + * + * "tape on a disk" emulator for MS-DOS and OS/2. + * + * Autor: Kai Uwe Rommel + * Datum: Thu 28-Dec-1989 + * Stand: Sun 14-Jan-1990 + * + * Compiler: MS C ab 5.00 + * System: OS/2 ab 1.1 + * + */ + +#include +#include +#include +#include + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifdef __32BIT__ +#include "diskacc2.h" +#else +#include "diskacc.h" +#endif + +#define SLOTS 4 + + +struct slot +{ + int handle; + unsigned sides, tracks, sectors; + unsigned long current, size; +}; + +static struct slot tbl[SLOTS]; + + +int dsk_isdev(char *path) +{ + return (isalpha(path[0]) && path[1] == ':' && path[2] == 0) || + (path[0] == '$' && isdigit(path[1]) && path[2] == ':' && path[3] == 0); +} + + +int dsk_open(char *path, int oflag, int logical) +{ + int cnt, fd; + + for ( cnt = 0; cnt < SLOTS; cnt++ ) + if ( tbl[cnt].handle == 0 ) + break; + + if ( cnt == SLOTS ) + return -1; + + fd = DskOpen(path, logical, 0, + &tbl[cnt].sides, &tbl[cnt].tracks, &tbl[cnt].sectors); + + if ( fd < 0 ) + return -1; + + tbl[cnt].handle = fd; + tbl[cnt].current = 0L; + tbl[cnt].size = 512L * tbl[cnt].sides * tbl[cnt].tracks * tbl[cnt].sectors; + + return cnt; +} + + +int dsk_close(int handle) +{ + if ( (handle < 0) || (SLOTS <= handle) ) + return -1; + + if ( tbl[handle].handle == 0 ) + return -1; + + DskClose(tbl[handle].handle); + tbl[handle].handle = 0; + + return 0; +} + + +int dsk_read(int handle, char *buf, unsigned nbyte) +{ + unsigned side, track, sector, nsects, ok, chunk; + + if ( (handle < 0) || (SLOTS <= handle) ) + return -1; + + if ( tbl[handle].handle == 0 ) + return -1; + + if ( nbyte % 512 != 0 ) + return -1; + + sector = (unsigned) (tbl[handle].current / 512L); + + track = sector / tbl[handle].sectors; + sector -= track * tbl[handle].sectors; + + side = track % tbl[handle].sides; + track /= tbl[handle].sides; + + nsects = nbyte / 512; + ok = 0; + + while ( nsects != 0 ) + { + if ( track >= tbl[handle].tracks ) + break; + + chunk = min(tbl[handle].sectors - sector, nsects); + + if ( DskRead(tbl[handle].handle, side, track, sector + 1, chunk, buf) != 0 ) + break; + + ok += chunk; + nsects -= chunk; + sector = 0; + + if ( ++side >= tbl[handle].sides ) + { + side = 0; + track++; + } + + tbl[handle].current += 512L * chunk; + buf += 512 * chunk; + } + + return ok * 512; +} + + +int dsk_write(int handle, char *buf, unsigned nbyte) +{ + unsigned side, track, sector, nsects, ok, chunk; + + if ( (handle < 0) || (SLOTS <= handle) ) + return -1; + + if ( tbl[handle].handle == 0 ) + return -1; + + if ( nbyte % 512 != 0 ) + return -1; + + sector = (unsigned) (tbl[handle].current / 512L); + + track = sector / tbl[handle].sectors; + sector -= track * tbl[handle].sectors; + + side = track % tbl[handle].sides; + track /= tbl[handle].sides; + + nsects = nbyte / 512; + ok = 0; + + while ( nsects != 0 ) + { + if ( track >= tbl[handle].tracks ) + break; + + chunk = min(tbl[handle].sectors - sector, nsects); + + if ( DskWrite(tbl[handle].handle, side, track, sector + 1, chunk, buf) != 0 ) + break; + + ok += chunk; + nsects -= chunk; + sector = 0; + + if ( ++side >= tbl[handle].sides ) + { + side = 0; + track++; + } + + tbl[handle].current += 512L * chunk; + buf += 512 * chunk; + } + + if ( nsects != 0 ) + errno = ENOSPC; + + return ok * 512; +} + + +long dsk_lseek(int handle, long offset, int where) +{ + if ( (handle < 0) || (SLOTS <= handle) ) + return -1; + + if ( tbl[handle].handle == 0 ) + return -1; + + if ( offset % 512L != 0L ) + return -1; + + switch ( where ) + { + case SEEK_SET: + tbl[handle].current = offset; + break; + case SEEK_CUR: + tbl[handle].current += offset; + break; + case SEEK_END: + tbl[handle].current = tbl[handle].size + offset; + break; + } + + if ( tbl[handle].current > tbl[handle].size ) + { + tbl[handle].current = 0L; + errno = EINVAL; + return -1L; + } + + return tbl[handle].current; +} + + +int dsk_size(int handle, long *total, long *cylinder) +{ + if ( (handle < 0) || (SLOTS <= handle) ) + return -1; + + if ( tbl[handle].handle == 0 ) + return -1; + + *total = tbl[handle].size; + *cylinder = (long) tbl[handle].sides * tbl[handle].sectors; + + return 0; +} + + +/* Ende DISKTAPE.C */ diff -Nur fileutils-3.13.org/lib/disktape.h fileutils-3.13/lib/disktape.h --- fileutils-3.13.org/lib/disktape.h Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/lib/disktape.h Thu Mar 16 18:10:00 1995 @@ -0,0 +1,34 @@ +/* DISKTAPE.H + * + * "tape on a disk" Emulator for MS-DOS and OS/2. + * + * Autor: Kai Uwe Rommel + * Datum: Thu 28-Dec-1989 + * Stand: Wed 4-Mar-1992 + * + * Compiler: MS C ab 5.10 + * System: OS/2 ab 1.1, PS/MS-DOS ab 3.20 + * + */ + + +int dsk_isdev(char *path); +int dsk_open(char *path, int oflag, int logical); +int dsk_close(int handle); +int dsk_read(int handle, char *buf, unsigned nbyte); +int dsk_write(int handle, char *buf, unsigned nbyte); +long dsk_lseek(int handle, long offset, int whence); +int dsk_size(int handle, long *total, long *cylinder); + + +#define _dev(p) dsk_isdev(p) +#define _dsk(f) ((f) >= 256) + +#define open(p, f, m) (_dev(p) ? dsk_open(p, f, use_logical) + 256 : open(p, f, m)) +#define read(f, b, n) (_dsk(f) ? dsk_read(f - 256, b, n) : read(f, b, n)) +#define write(f, b, n) (_dsk(f) ? dsk_write(f - 256, b, n) : write(f, b, n)) +#define lseek(f, o, w) (_dsk(f) ? dsk_lseek(f - 256, o, w) : lseek(f, o, w)) +#define close(f) (_dsk(f) ? dsk_close(f - 256) : close(f)) + + +/* Ende DISKTAPE.H */ diff -Nur fileutils-3.13.org/lib/error.c fileutils-3.13/lib/error.c --- fileutils-3.13.org/lib/error.c Thu Apr 18 23:02:42 1996 +++ fileutils-3.13/lib/error.c Fri Aug 2 08:26:44 1996 @@ -91,6 +91,17 @@ # endif /* HAVE_STRERROR */ #endif /* _LIBC */ +#ifdef __EMX__ + +char *program_name; + +void set_program_name(char *name) +{ + program_name = name; +} + +#endif + /* Print the program name and error message MESSAGE, which is a printf-style format string with optional args. If ERRNUM is nonzero, print its corresponding system error message. diff -Nur fileutils-3.13.org/lib/euidaccess.c fileutils-3.13/lib/euidaccess.c --- fileutils-3.13.org/lib/euidaccess.c Tue May 21 12:04:28 1996 +++ fileutils-3.13/lib/euidaccess.c Fri Aug 2 08:26:46 1996 @@ -44,6 +44,7 @@ # include #endif +#ifndef OS2 #ifdef _POSIX_VERSION # include # if !defined(NGROUPS_MAX) || NGROUPS_MAX < 1 @@ -61,6 +62,7 @@ # define NGROUPS_MAX NGROUPS # endif /* not NGROUPS_MAX and NGROUPS */ #endif /* not POSIX_VERSION */ +#endif #include #ifndef errno diff -Nur fileutils-3.13.org/lib/fnmatch.c fileutils-3.13/lib/fnmatch.c --- fileutils-3.13.org/lib/fnmatch.c Fri Jan 27 17:16:18 1995 +++ fileutils-3.13/lib/fnmatch.c Fri Aug 2 08:26:46 1996 @@ -52,6 +52,10 @@ register const char *p = pattern, *n = string; register char c; +#ifdef OS2 + flags |= FNM_CASEFOLD; +#endif + /* Note that this evalutes C many times. */ #define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c)) diff -Nur fileutils-3.13.org/lib/fsusage.c fileutils-3.13/lib/fsusage.c --- fileutils-3.13.org/lib/fsusage.c Thu May 23 12:53:44 1996 +++ fileutils-3.13/lib/fsusage.c Tue Mar 31 06:59:44 1998 @@ -60,6 +60,12 @@ int safe_read (); +#ifdef OS2 +#define INCL_NOPM +#define INCL_DOS +#include +#endif + /* Return the number of TOSIZE-byte blocks used by BLOCKS FROMSIZE-byte blocks, rounding away from zero. TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */ @@ -201,7 +207,23 @@ adjust_blocks ((b), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512) #endif -#if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS) /* !Ultrix && !SVR2. */ +#ifdef OS2 + FSALLOCATE fsalloc; + LONG cluster; + + if ( DosQueryFSInfo(path[0] - '@', 1, (PBYTE) &fsalloc, sizeof(fsalloc)) ) + return -1; + + cluster = fsalloc.cSectorUnit * fsalloc.cbSector; + fsp->fsu_blocks = (cluster / 512) * fsalloc.cUnit; + fsp->fsu_bfree = (cluster / 512) * fsalloc.cUnitAvail; + fsp->fsu_bavail = fsp->fsu_bfree; + fsp->fsu_files = 0; + fsp->fsu_ffree = 0; +#endif + +#if !defined(OS2) && !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS) + /* !OS/2 && !Ultrix && !SVR2. */ fsp->fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks); fsp->fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree); fsp->fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail); diff -Nur fileutils-3.13.org/lib/fu.def fileutils-3.13/lib/fu.def --- fileutils-3.13.org/lib/fu.def Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/lib/fu.def Wed May 5 11:34:12 2004 @@ -0,0 +1,93 @@ +LIBRARY FU INITGLOBAL +DESCRIPTION 'GNU file utilities common library' +DATA MULTIPLE NONSHARED + +EXPORTS + argmatch @1 + invalid_arg @2 + backup_type @3 + find_backup_file_name @4 + simple_backup_suffix @5 + basename @6 + dirname @7 + euidaccess @8 +; eaccess_stat @9 + error @10 + set_program_name @11 + filemodestring @12 + mode_string @13 + fnmatch @14 + get_fs_usage @15 + getopt @16 + optarg @17 + opterr @18 + optind @19 + getopt_long @20 + getopt_long_only @21 + parse_user_spec @22 + get_version @23 + getgidbyname @24 + getgroup @25 + getuidbyname @26 + getuser @27 + isdir @28 + make_path @29 + mode_adjust @30 + mode_compile @31 + mode_free @32 + savedir @33 + stpcpy @34 + fix_colon @35 + strip_trailing_slashes @36 + xgetcwd @37 + xmalloc @38 + xrealloc @39 + xstrdup @40 + yesno @41 + get_date @42 + getdate_yyparse @45 + posixtime @46 + posixtime_zzparse @47 + posixtm @48 + read_filesystem_list @49 + CopyEAs @50 + GetEAs @51 + SetEAs @52 + dsk_close @53 + dsk_isdev @54 + dsk_lseek @55 + dsk_open @56 + dsk_read @57 + dsk_size @58 + dsk_write @59 + UnixFileName @60 + DskClose @61 + DskOpen @62 + DskRead @63 + DskWrite @64 + modestring @65 + getfmode @66 + setfmode @67 + IsUpper @68 + IsLower @69 + ToUpper @70 + ToLower @71 + full_write @72 + safe_read @73 + parse_long_options @74 + _obstack_allocated_p @75 + _obstack_begin @76 + _obstack_begin_1 @77 + _obstack_free @78 + _obstack_newchunk @79 + obstack_free @80 + save_cwd @81 + restore_cwd @82 + free_cwd @83 + strcasecmp @84 + strndup @85 + xstrtol @86 + xstrtoul @87 + getline @88 + getstr @89 + getdelim @90 diff -Nur fileutils-3.13.org/lib/full-write.c fileutils-3.13/lib/full-write.c --- fileutils-3.13.org/lib/full-write.c Tue Feb 27 03:57:26 1996 +++ fileutils-3.13/lib/full-write.c Mon Sep 2 17:36:48 1996 @@ -28,6 +28,10 @@ #include #endif +#ifdef OS2 +#include +#endif + #include #ifndef errno extern int errno; diff -Nur fileutils-3.13.org/lib/idcache.c fileutils-3.13/lib/idcache.c --- fileutils-3.13.org/lib/idcache.c Sun Oct 2 05:35:32 1994 +++ fileutils-3.13/lib/idcache.c Fri Aug 2 08:26:46 1996 @@ -21,8 +21,10 @@ #include #include +#ifndef OS2 #include #include +#endif #if defined(STDC_HEADERS) || defined(HAVE_STRING_H) #include @@ -66,6 +68,9 @@ getuser (uid) uid_t uid; { +#ifdef OS2 + return "user"; +#else register struct userid *tail; struct passwd *pwent; char usernum_string[20]; @@ -89,6 +94,7 @@ tail->next = user_alist; user_alist = tail; return tail->name; +#endif } /* Translate USER to a UID, with cache. @@ -100,6 +106,10 @@ getuidbyname (user) char *user; { +#ifdef OS2 + static uid_t uid = 0; + return &uid; +#else register struct userid *tail; struct passwd *pwent; @@ -130,6 +140,7 @@ tail->next = nouser_alist; nouser_alist = tail; return 0; +#endif } /* Use the same struct as for userids. */ @@ -143,6 +154,9 @@ getgroup (gid) gid_t gid; { +#ifdef OS2 + return "group"; +#else register struct userid *tail; struct group *grent; char groupnum_string[20]; @@ -166,6 +180,7 @@ tail->next = group_alist; group_alist = tail; return tail->name; +#endif } /* Translate GROUP to a UID, with cache. @@ -177,6 +192,10 @@ getgidbyname (group) char *group; { +#ifdef OS2 + static gid_t gid = 0; + return &gid; +#else register struct userid *tail; struct group *grent; @@ -207,4 +226,5 @@ tail->next = nogroup_alist; nogroup_alist = tail; return 0; +#endif } diff -Nur fileutils-3.13.org/lib/Makefile.os2 fileutils-3.13/lib/Makefile.os2 --- fileutils-3.13.org/lib/Makefile.os2 Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/lib/Makefile.os2 Wed May 5 11:34:12 2004 @@ -0,0 +1,51 @@ +# Makefile for library files used by GNU fileutils. +# Do not use this makefile directly, but only from `../Makefile'. +# Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc. + +OBJECTS = argmatch$O backupfile$O basename$O dirname$O euidaccess$O \ +error$O filemode$O fnmatch$O fsusage$O getopt$O getopt1$O userspec$O \ +getversion$O idcache$O isdir$O makepath$O modechange$O savedir$O stpcpy$O \ +stripslash$O xgetcwd$O xmalloc$O xstrdup$O yesno$O getdate$O posixtm$O \ +mountlist$O full-write$O safe-read$O long-options$O obstack$O \ +save-cwd$O xstrtol$O xstrtoul$O strndup$O strcasecmp$O getline$O \ +os2lib$O disktape$O diskacc2$O + +.SUFFIXES: .c $O + +.c$O: + $(CC) $(CFLAGS) -c $< + +.PHONY: lib dll +lib: fu.a +dll: fu.dll fu.lib + +$(OBJECTS): ../config.h + +fu.a: $(OBJECTS) + rm -f $@ + $(AR) cr $@ $(OBJECTS) + $(RANLIB) $@ + +fu.lib: fu.def + emximp -o $@ fu.def + +fu.dll: fu.def $(OBJECTS) + $(CC) fu.def -o $@ $(OBJECTS) $(DLFLAGS) + +getdate.c: getdate.y + bison -o getdate.c getdate.y + +posixtm.c: posixtm.y + bison -o posixtm.tab.c posixtm.y + sed -e "s/yy/zz/g" posixtm.tab.c > posixtm.c + rm -f posixtm.tab.c + +backupfile$O getversion$O: backupfile.h +fnmatch$O: fnmatch.h +fsusage$O: fsusage.h +getopt1$O: getopt.h +modechange$O: modechange.h +mountlist$O: mountlist.h + +clean: + rm -f *.o *.obj *.a *.lib diff -Nur fileutils-3.13.org/lib/makepath.c fileutils-3.13/lib/makepath.c --- fileutils-3.13.org/lib/makepath.c Fri May 19 15:23:20 1995 +++ fileutils-3.13/lib/makepath.c Fri Aug 2 08:26:48 1996 @@ -160,6 +160,10 @@ } slash = dirpath; +#ifdef OS2 + if (isalpha(slash[0]) && slash[1] == ':') + slash += 2; +#endif while (*slash == '/') slash++; while ((slash = strchr (slash, '/'))) diff -Nur fileutils-3.13.org/lib/modechange.c fileutils-3.13/lib/modechange.c --- fileutils-3.13.org/lib/modechange.c Thu May 16 03:49:34 1996 +++ fileutils-3.13/lib/modechange.c Fri Aug 2 08:26:48 1996 @@ -99,8 +99,12 @@ return head; } +#ifdef OS2 + umask_value = 022; +#else umask_value = umask (0); umask (umask_value); /* Restore the old value. */ +#endif head = NULL; #ifdef lint @@ -127,7 +131,11 @@ affected_bits |= 01007; break; case 'a': +#ifdef OS2 + affected_bits = 077777; +#else affected_bits |= 07777; +#endif break; default: goto no_more_affected; @@ -138,7 +146,11 @@ set in the umask. */ if (affected_bits == 0) { +#ifdef OS2 + affected_bits = 077777; +#else affected_bits = 07777; +#endif ops_to_mask = masked_ops; } @@ -193,8 +205,20 @@ break; case 's': /* Set the setuid/gid bits if `u' or `g' is selected. */ +#ifdef OS2 /* no, system flag under DOS and OS/2 */ + change->value |= 040000; +#else change->value |= 06000 & affected_masked; +#endif break; +#ifdef OS2 + case 'h': + change->value |= 020000; + break; + case 'a': + change->value |= 010000; + break; +#endif case 't': /* Set the "save text image" bit if `o' is selected. */ change->value |= 01000 & affected_masked; @@ -249,7 +273,11 @@ unsigned short newmode; /* The adjusted mode and one operand. */ unsigned short value; /* The other operand. */ +#ifdef OS2 + newmode = oldmode & 077777; +#else newmode = oldmode & 07777; +#endif for (; changes; changes = changes->next) { diff -Nur fileutils-3.13.org/lib/mountlist.c fileutils-3.13/lib/mountlist.c --- fileutils-3.13.org/lib/mountlist.c Wed May 22 00:59:28 1996 +++ fileutils-3.13/lib/mountlist.c Fri Aug 2 08:26:48 1996 @@ -49,6 +49,12 @@ # include #endif /* MOUNTED_GETFSSTAT */ +#ifdef OS2 +#define INCL_NOPM +#define INCL_DOS +#include +#endif + #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ #include #if !defined(MOUNTED) @@ -460,6 +466,90 @@ return NULL; } #endif /* MOUNTED_GETMNTENT2. */ + +#ifdef OS2 + { + int val; + char name[8], type[32]; + HFILE handle; + ULONG action, result, cbData; + BOOL fixed; + PVOID pParmList; + BYTE bDataArea[64]; + ULONG ParmLengthMax, ParmLengthInOut, DataLengthMax, DataLengthInOut; + PFSQBUFFER2 pData = (PFSQBUFFER2) bDataArea; + FSINFO fsinfo; + + for ( val = 1; val <= 26; val++ ) + { + if (val < 3 && (all_fs & val) == 0) + continue; + + name[0] = (char) (val + '@'); + name[1] = ':'; + name[2] = 0; + + if ( DosOpen(name, &handle, &action, 0L, FILE_NORMAL, FILE_OPEN, + OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR | + OPEN_ACCESS_READONLY | OPEN_SHARE_DENYREADWRITE, 0L) != 0 ) + continue; + + pParmList = NULL; + ParmLengthMax = ParmLengthInOut = 0; + DataLengthMax = sizeof(bDataArea); + DataLengthInOut = 0; + + result = DosDevIOCtl(handle, 8, 0x20, + pParmList, ParmLengthMax, &ParmLengthInOut, + bDataArea, DataLengthMax, &DataLengthInOut); + DosClose(handle); + + fixed = bDataArea[0]; + + if ( result ) + continue; + + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + + me->me_mountdir = xstrdup (name); + + cbData = sizeof(bDataArea); + if ( DosQueryFSAttach(name, 0, FSAIL_QUERYNAME, pData, &cbData) == 0 ) + { + strcpy(type, pData -> szFSDName + pData -> cbName); + + switch ( pData -> iType ) + { + case 3: + strcat(type, ", local"); + break; + case 4: + strcat(type, ", remote"); + break; + } + + strcat(type, ", "); + } + else + type[0] = 0; + + strcat(type, fixed ? "fixed" : "removable"); + me->me_type = xstrdup(type); + + if ( DosQueryFSInfo(val, 2, (PBYTE) &fsinfo, sizeof(fsinfo)) == 0 ) + me->me_devname = xstrdup(fsinfo.vol.szVolLabel); + else + me->me_devname = ""; + + me->me_dev = val; + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + } +#endif #ifdef MOUNTED_VMOUNT /* AIX. */ { diff -Nur fileutils-3.13.org/lib/os2lib.c fileutils-3.13/lib/os2lib.c --- fileutils-3.13.org/lib/os2lib.c Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/lib/os2lib.c Tue Mar 31 07:21:46 1998 @@ -0,0 +1,213 @@ +/* OS/2 32-bit EA code, (c) 1992 Kai Uwe Rommel */ + +#define INCL_NOPM +#define INCL_DOS +#define INCL_DOSNLS +#include + +#include +#include +#include + +void GetEAs(char *path, char **bufptr, unsigned *size) +{ + PDENA2 pDENA, pFound; + EAOP2 eaop; + PGEA2 pGEA; + PGEA2LIST pGEAlist; + PFEA2LIST pFEAlist; + PVOID pEAblock; + ULONG ulAttributes; + ULONG nLength; + ULONG nBlock; + char szName[CCHMAXPATH]; + + *size = 0; + + if ( _osmode == DOS_MODE ) + return; + + strcpy(szName, path); + nLength = strlen(szName); + if ( szName[nLength - 1] == '/' ) + szName[nLength - 1] = 0; + + nBlock = 65535; + if ( (pDENA = alloca((size_t) nBlock)) == NULL ) + return; + + ulAttributes = -1; + + if ( DosEnumAttribute(ENUMEA_REFTYPE_PATH, szName, 1, pDENA, nBlock, + &ulAttributes, ENUMEA_LEVEL_NO_VALUE) + || ulAttributes == 0 + || (pGEAlist = alloca((size_t) nBlock)) == NULL ) + return; + + pGEA = pGEAlist -> list; + pFound = pDENA; + + while ( ulAttributes-- ) + { + pGEA -> cbName = pFound -> cbName; + strcpy(pGEA -> szName, pFound -> szName); + + nLength = sizeof(GEA2) + strlen(pGEA -> szName); + nLength = ((nLength - 1) / sizeof(ULONG) + 1) * sizeof(ULONG); + + pGEA -> oNextEntryOffset = ulAttributes ? nLength : 0; + pGEA = (PGEA2) ((PCH) pGEA + nLength); + + pFound = (PDENA2) ((PCH) pFound + pFound -> oNextEntryOffset); + } + + if ( pGEA == pGEAlist -> list ) + return; + + pGEAlist -> cbList = (PCH) pGEA - (PCH) pGEAlist; + + pFEAlist = (PVOID) pDENA; /* reuse buffer */ + pFEAlist -> cbList = nBlock; + + eaop.fpGEA2List = pGEAlist; + eaop.fpFEA2List = pFEAlist; + eaop.oError = 0; + + if ( DosQueryPathInfo(szName, FIL_QUERYEASFROMLIST, + (PBYTE) &eaop, sizeof(eaop)) ) + return; + + if ( (pEAblock = malloc(pFEAlist -> cbList)) == NULL ) + return; + + memcpy(pEAblock, pFEAlist, pFEAlist -> cbList); + + *bufptr = (char *) pEAblock; + *size = pFEAlist -> cbList; +} + +void SetEAs(char *path, char *eablock) +{ + EAOP2 eaop; + USHORT nLength; + char szName[CCHMAXPATH]; + + if ( _osmode == DOS_MODE ) + return; + + strcpy(szName, path); + nLength = strlen(szName); + if (szName[nLength - 1] == '/') + szName[nLength - 1] = 0; + + eaop.fpGEA2List = NULL; + eaop.fpFEA2List = (PFEA2LIST) eablock; + eaop.oError = 0; + + DosSetPathInfo(szName, FIL_QUERYEASIZE, (PBYTE) &eaop, sizeof(eaop), 0); +} + +void CopyEAs(char *src_path, char *dst_path) +{ + char *eablock; + unsigned easize; + + GetEAs(src_path, &eablock, &easize); + + if ( easize ) + { + SetEAs(dst_path, eablock); + free(eablock); + } +} + +int getfmode(char *name) +{ + FILESTATUS3 fs; + return DosQueryPathInfo(name, 1, &fs, sizeof(fs)) ? -1 : fs.attrFile; +} + +int setfmode(char *name, unsigned mode) +{ + FILESTATUS3 fs; + if ( DosQueryPathInfo(name, 1, &fs, sizeof(fs)) ) + return -1; + fs.attrFile = mode; + return DosSetPathInfo(name, 1, (PBYTE) &fs, sizeof(fs), 0) ? -1 : 0; +} + +char *modestring(unsigned mode) +{ + static char buf[8]; + + buf[0] = (mode & FILE_HIDDEN) ? 'h' : '-'; + buf[1] = (mode & FILE_SYSTEM) ? 's' : '-'; + buf[2] = (mode & FILE_ARCHIVED) ? 'a' : '-'; + buf[3] = 0; + + return buf; +} + +void UnixFileName(char *name) +{ + for ( ; *name; name++ ) + if ( *name == '\\' ) + *name = '/'; +} + +static unsigned char cUpperCase[256], cLowerCase[256]; +static BOOL bInitialized; + +static void InitNLS(void) +{ + unsigned nCnt, nU; + COUNTRYCODE cc; + + bInitialized = TRUE; + + for ( nCnt = 0; nCnt < 256; nCnt++ ) + cUpperCase[nCnt] = cLowerCase[nCnt] = (unsigned char) nCnt; + + cc.country = cc.codepage = 0; + DosMapCase(sizeof(cUpperCase), &cc, (PCHAR) cUpperCase); + + for ( nCnt = 0; nCnt < 256; nCnt++ ) + { + nU = cUpperCase[nCnt]; + if (nU != nCnt && cLowerCase[nU] == (unsigned char) nU) + cLowerCase[nU] = (unsigned char) nCnt; + } + + for ( nCnt = 'A'; nCnt <= 'Z'; nCnt++ ) + cLowerCase[nCnt] = (unsigned char) (nCnt - 'A' + 'a'); +} + +int IsLower(int c) +{ + if ( !bInitialized ) + InitNLS(); + return (cUpperCase[c] != (unsigned char) c) + || (c == 0xE1); /* special case, german "sz" */ +} + +int IsUpper(int c) +{ + if ( !bInitialized ) + InitNLS(); + return (cLowerCase[c] != (unsigned char) c); +} + +int ToLower(int c) +{ + if ( !bInitialized ) + InitNLS(); + return cLowerCase[(unsigned char) c]; +} + +int ToUpper(int c) +{ + if ( !bInitialized ) + InitNLS(); + return cUpperCase[(unsigned char) c]; +} + diff -Nur fileutils-3.13.org/lib/safe-read.c fileutils-3.13/lib/safe-read.c --- fileutils-3.13.org/lib/safe-read.c Sun Jan 8 19:33:34 1995 +++ fileutils-3.13/lib/safe-read.c Mon Sep 2 17:37:02 1996 @@ -31,6 +31,10 @@ extern int errno; #endif +#ifdef OS2 +#include +#endif + /* Read LEN bytes at PTR from descriptor DESC, retrying if interrupted. Return the actual number of bytes read, zero for EOF, or negative for an error. */ diff -Nur fileutils-3.13.org/lib/save-cwd.c fileutils-3.13/lib/save-cwd.c --- fileutils-3.13.org/lib/save-cwd.c Fri Dec 8 20:19:48 1995 +++ fileutils-3.13/lib/save-cwd.c Fri Aug 2 10:16:54 1996 @@ -45,6 +45,10 @@ #include "save-cwd.h" #include "error.h" +#ifdef OS2 +#define chdir(d) _chdir2(d) +#endif + char *xgetcwd __P((void)); /* Record the location of the current working directory in CWD so that diff -Nur fileutils-3.13.org/lib/savedir.c fileutils-3.13/lib/savedir.c --- fileutils-3.13.org/lib/savedir.c Thu Oct 20 16:17:00 1994 +++ fileutils-3.13/lib/savedir.c Fri Aug 2 08:26:48 1996 @@ -85,6 +85,13 @@ if (dirp == NULL) return NULL; +#ifdef OS2 /* stat () it ourselves ... */ + name_size = 0; + for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp)) + name_size += strlen(dp->d_name) + 1; + seekdir(dirp, 0L); +#endif /* OS2 */ + name_space = (char *) malloc (name_size); if (name_space == NULL) { diff -Nur fileutils-3.13.org/lib/strcasecmp.c fileutils-3.13/lib/strcasecmp.c --- fileutils-3.13.org/lib/strcasecmp.c Wed May 1 05:22:14 1996 +++ fileutils-3.13/lib/strcasecmp.c Fri Aug 2 10:35:20 1996 @@ -21,6 +21,11 @@ #include #include +#ifdef __EMX__ +#define tolower(c) ToLower(c) +#define toupper(c) ToUpper(c) +#endif + /* Compare S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexiographically less than, equal to or greater than S2. */ diff -Nur fileutils-3.13.org/lib/stripslash.c fileutils-3.13/lib/stripslash.c --- fileutils-3.13.org/lib/stripslash.c Sun Oct 2 05:35:40 1994 +++ fileutils-3.13/lib/stripslash.c Fri Aug 2 08:26:48 1996 @@ -24,6 +24,7 @@ #else #include #endif +#include /* Remove trailing slashes from PATH. This is useful when using filename completion from a shell that @@ -38,6 +39,30 @@ int last; last = strlen (path) - 1; +#ifdef OS2 + UnixFileName (path); + if (last != 2 || !isalpha(path[0]) || path[1] != ':') +#endif while (last > 0 && path[last] == '/') path[last--] = '\0'; } + +#ifdef OS2 +char * +fix_colon (path) + char *path; +{ + int len = strlen (path); + char *new_path; + extern char *xmalloc (); + + if (path[len - 1] == ':') { + new_path = xmalloc (len + 2); + strcpy(new_path, path); + strcat(new_path, "."); + return new_path; + } + else + return path; +} +#endif diff -Nur fileutils-3.13.org/lib/userspec.c fileutils-3.13/lib/userspec.c --- fileutils-3.13.org/lib/userspec.c Wed Oct 18 15:59:12 1995 +++ fileutils-3.13/lib/userspec.c Fri Aug 2 08:26:48 1996 @@ -37,8 +37,10 @@ #include #include +#ifndef OS2 #include #include +#endif #ifdef HAVE_STRING_H # include @@ -83,7 +85,9 @@ } \ while (0) +#ifndef isdigit #define isdigit(c) ((c) >= '0' && (c) <= '9') +#endif char *strdup (); @@ -155,6 +159,9 @@ if (u != NULL) { +#ifdef OS2 + *uid = *gid = 0; +#else pwd = getpwnam (u); if (pwd == NULL) { @@ -197,11 +204,15 @@ } } endpwent (); +#endif } if (g != NULL && error_msg == NULL) { /* Explicit group. */ +#ifdef OS2 + *gid = 0; +#else grp = getgrnam (g); if (grp == NULL) { @@ -213,6 +224,7 @@ else *gid = grp->gr_gid; endgrent (); /* Save a file descriptor. */ +#endif if (error_msg == NULL) V_STRDUP (groupname, g); diff -Nur fileutils-3.13.org/lib/xgetcwd.c fileutils-3.13/lib/xgetcwd.c --- fileutils-3.13.org/lib/xgetcwd.c Thu Sep 29 17:33:52 1994 +++ fileutils-3.13/lib/xgetcwd.c Fri Aug 2 08:26:50 1996 @@ -33,7 +33,14 @@ char *getwd (); #define getcwd(buf, max) getwd (buf) #else +#ifndef getcwd char *getcwd (); +#endif +#endif + +#ifdef OS2 +#include +#define getcwd(b, s) _getcwd2(b, s) #endif /* Amount to increase buffer size by in each try. */ diff -Nur fileutils-3.13.org/src/chmod.c fileutils-3.13/src/chmod.c --- fileutils-3.13.org/src/chmod.c Thu May 16 03:29:54 1996 +++ fileutils-3.13/src/chmod.c Fri Aug 2 09:08:50 1996 @@ -105,6 +105,9 @@ struct stat file_stats; unsigned short newmode; int errors = 0; +#ifdef OS2 + unsigned extmode = getfmode(file); +#endif if (lstat (file, &file_stats)) { @@ -127,8 +130,30 @@ } #endif +#ifdef OS2 + if ( extmode & A_ARCHIVE ) + file_stats.st_mode |= 010000; + if ( extmode & A_HIDDEN ) + file_stats.st_mode |= 020000; + if ( extmode & A_SYSTEM ) + file_stats.st_mode |= 040000; +#endif + newmode = mode_adjust (file_stats.st_mode, changes); +#ifdef OS2 + if ( (file_stats.st_mode & S_IFMT) != S_IFDIR ) + { + extmode &= ~(A_ARCHIVE | A_HIDDEN | A_SYSTEM); + if ( newmode & 010000 ) + extmode |= A_ARCHIVE; + if ( newmode & 020000 ) + extmode |= A_HIDDEN; + if ( newmode & 040000 ) + extmode |= A_SYSTEM; + setfmode(file, extmode); +#endif + if (newmode != (file_stats.st_mode & 07777)) { if (verbose) @@ -143,6 +168,10 @@ else if (verbose && changes_only == 0) describe_change (file, newmode, 0); +#ifdef OS2 + } +#endif + if (recurse && S_ISDIR (file_stats.st_mode)) errors |= change_dir_mode (file, changes, &file_stats); return errors; @@ -204,6 +233,7 @@ static void usage (int status) { + print_version("chmod"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); @@ -252,7 +282,7 @@ { thisind = optind ? optind : 1; - c = getopt_long (argc, argv, "RcfvrwxXstugoa,+-=", long_options, + c = getopt_long (argc, argv, "RcfvrwxXstugoah,+-=", long_options, (int *) 0); if (c == EOF) break; @@ -271,6 +301,9 @@ case 'g': case 'o': case 'a': +#ifdef OS2 + case 'h': +#endif case ',': case '+': case '-': @@ -311,8 +344,12 @@ if (optind >= argc) { +#ifdef OS2 + usage (0); +#else error (0, 0, _("too few arguments")); usage (1); +#endif } changes = mode_compile (argv[modeind], diff -Nur fileutils-3.13.org/src/chown.c fileutils-3.13/src/chown.c --- fileutils-3.13.org/src/chown.c Sun May 19 14:37:34 1996 +++ fileutils-3.13/src/chown.c Fri Aug 2 09:08:08 1996 @@ -309,8 +309,12 @@ if (optind >= argc - 1) { +#ifdef OS2 + usage (0); +#else error (0, 0, _("too few arguments")); usage (1); +#endif } #ifndef HAVE_LCHOWN diff -Nur fileutils-3.13.org/src/cp-aux.c fileutils-3.13/src/cp-aux.c --- fileutils-3.13.org/src/cp-aux.c Sat Jul 6 22:38:08 1996 +++ fileutils-3.13/src/cp-aux.c Fri Aug 2 08:26:50 1996 @@ -27,6 +27,7 @@ void usage (int status, const char *reason) { + print_version("cp"); if (reason != NULL) fprintf (status == 0 ? stdout : stderr, "%s: %s\n", program_name, reason); diff -Nur fileutils-3.13.org/src/cp.c fileutils-3.13/src/cp.c --- fileutils-3.13.org/src/cp.c Fri Jun 21 15:29:54 1996 +++ fileutils-3.13/src/cp.c Fri Aug 2 09:07:44 1996 @@ -40,6 +40,15 @@ # define chown(PATH, OWNER, GROUP) lchown(PATH, OWNER, GROUP) #endif +#ifdef OS2 +#define is_ancestor(statb, ancestors) 0 +#define hash_init(module, size) +#define remember_copied(path, ino, dev) NULL +#define remember_created(path) 0 +#define forget_all() +char new_file; +#endif + /* Used by do_copy, make_path_private, and re_protect to keep a list of leading directories whose protections need to be fixed after copying. */ @@ -225,7 +234,11 @@ that created directories can be written, even if it would not have been allowed with the mask this process was started with. */ +#ifdef OS2 /* not 100%ly correct ... */ + umask_kill = 07777 ^ 022 /* umask (0) */ ; +#else umask_kill = 0777777 ^ umask (0); +#endif while ((c = getopt_long (argc, argv, "abdfilprsuvxPRS:V:", long_opts, (int *) 0)) != EOF) @@ -346,7 +359,11 @@ backup_type = get_version (version); if (flag_preserve == 1) +#ifdef OS2 /* not 100%ly correct ... */ + umask_kill = 07777; +#else umask_kill = 0777777; +#endif /* The key difference between -d (--no-dereference) and not is the version of `stat' to call. */ @@ -399,11 +416,19 @@ int ret = 0; if (optind >= argc) +#ifdef OS2 + usage (0, NULL); +#else usage (2, _("missing file arguments")); +#endif if (optind >= argc - 1) usage (2, _("missing destination file")); dest = argv[argc - 1]; +#ifdef OS2 + dest = fix_colon(dest); + UnixFileName(dest); +#endif if (lstat (dest, &sb)) { @@ -446,8 +471,14 @@ if (flag_path) { + ap = arg; +#ifdef OS2 + if ( ap[1] == ':' && isalpha(ap[0]) ) + ap += 2; +#endif + /* Append all of `arg' to `dest'. */ - dst_path = path_concat (dest, arg); + dst_path = path_concat (dest, ap); /* For --parents, we have to make sure that the directory dirname (dst_path) exists. We may have to create a few @@ -481,7 +512,9 @@ if (flag_path) { +#ifndef OS2 ret |= re_protect (dst_path, strlen (dest) + 1, attr_list); +#endif } } @@ -619,6 +652,20 @@ else { /* The file exists already. */ +#ifdef OS2 + char f_dst_path[PATH_MAX], f_src_path[PATH_MAX]; + + _abspath(f_dst_path, dst_path, PATH_MAX); + _abspath(f_src_path, src_path, PATH_MAX); + + if (_fncmp (f_dst_path, f_src_path) == 0) +#else + if (strcmp (dst_path, src_path) == 0) +#endif + { + error (0, 0, "`%s': can't copy file to itself", src_path); + return 1; + } if (src_sb.st_ino == dst_sb.st_ino && src_sb.st_dev == dst_sb.st_dev) { @@ -698,6 +745,7 @@ { if (S_ISDIR (dst_sb.st_mode)) { +#ifndef OS2 /* Temporarily change mode to allow overwriting. */ if (euidaccess (dst_path, W_OK | X_OK) != 0) { @@ -709,6 +757,7 @@ else fix_mode = 1; } +#endif } else { @@ -730,6 +779,7 @@ if (flag_verbose && !S_ISDIR (src_type)) printf ("%s -> %s\n", src_path, dst_path); +#ifndef OS2 /* Did we copy this inode somewhere else (in this command line argument) and therefore this is a second hard link to the inode? */ @@ -742,6 +792,7 @@ } return 0; } +#endif if (S_ISDIR (src_type)) { @@ -835,6 +886,7 @@ goto un_backup; } else +#ifndef OS2 #ifdef S_ISFIFO if (S_ISFIFO (src_type)) { @@ -859,6 +911,7 @@ } } else +#endif #ifdef S_ISLNK if (S_ISLNK (src_type)) { @@ -888,6 +941,10 @@ goto un_backup; } +#ifdef OS2 + CopyEAs(src_path, dst_path); +#endif + /* Adjust the times (and if possible, ownership) for the copy. chown turns off set[ug]id bits for non-root, so do the chmod last. */ @@ -899,7 +956,11 @@ utb.actime = src_sb.st_atime; utb.modtime = src_sb.st_mtime; +#ifdef OS2 + if (S_ISREG (src_type) && utime (dst_path, &utb)) +#else if (utime (dst_path, &utb)) +#endif { error (0, errno, "%s", dst_path); return 1; @@ -918,9 +979,18 @@ } if ((flag_preserve || new_dst) +#ifdef OS2 + && (flag_copy_as_regular && !S_ISDIR (src_type) || S_ISREG (src_type))) +#else && (flag_copy_as_regular || S_ISREG (src_type) || S_ISDIR (src_type))) +#endif { +#ifdef OS2 + if (chmod (dst_path, src_mode & umask_kill) || + setfmode(dst_path, getfmode(src_path))) +#else if (chmod (dst_path, src_mode & umask_kill)) +#endif { error (0, errno, "%s", dst_path); return 1; @@ -1222,7 +1292,7 @@ int last_write_made_hole = 0; int make_holes = (flag_sparse == SPARSE_ALWAYS); - source_desc = open (src_path, O_RDONLY); + source_desc = open (src_path, O_RDONLY | O_BINARY); if (source_desc < 0) { error (0, errno, "%s", src_path); @@ -1232,7 +1302,7 @@ /* Create the new regular file with small permissions initially, to not create a security hole. */ - dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600); + dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600); if (dest_desc < 0) { error (0, errno, _("cannot create regular file `%s'"), dst_path); diff -Nur fileutils-3.13.org/src/dcgen.pl fileutils-3.13/src/dcgen.pl --- fileutils-3.13.org/src/dcgen.pl Sun Jun 23 15:11:30 1996 +++ fileutils-3.13/src/dcgen.pl Fri Aug 2 09:35:36 1996 @@ -1,4 +1,4 @@ -#!@PERL@ -w +#!perl -w # -*- perl -*- # @configure_input@ diff -Nur fileutils-3.13.org/src/dd.c fileutils-3.13/src/dd.c --- fileutils-3.13.org/src/dd.c Fri Jul 5 02:28:46 1996 +++ fileutils-3.13/src/dd.c Sat Aug 10 11:12:00 1996 @@ -65,8 +65,15 @@ #include "system.h" #include "error.h" +#ifdef OS2 +#undef _POSIX_VERSION +#include "disktape.h" +#endif + #define equal(p, q) (strcmp ((p),(q)) == 0) +#ifndef max #define max(a, b) ((a) > (b) ? (a) : (b)) +#endif #define output_char(c) \ do { \ obuf[oc++] = (c); if (oc >= output_blocksize) write_output (); \ @@ -171,6 +178,12 @@ static unsigned char newline_character = '\n'; static unsigned char space_character = ' '; +/* echo progress */ +int echo_progress = 0; + +/* use logical disk parameters rather than physical ones for floppies */ +int use_logical = 0; + struct conversion { char *convname; @@ -350,12 +363,15 @@ if (input_file != NULL) { - input_fd = open (input_file, O_RDONLY); + input_fd = open (input_file, O_RDONLY | O_BINARY, 0); if (input_fd < 0) error (1, errno, "%s", input_file); } else - input_file = _("standard input"); + if (isatty (fileno(stdin))) + usage(0); + else + input_file = _("standard input"); if (input_fd == output_fd) error (1, 0, _("%s is closed"), (input_fd == 0 @@ -364,7 +380,7 @@ if (output_file != NULL) { - int omode = O_RDWR | O_CREAT; + int omode = O_RDWR | O_CREAT | O_BINARY; if (seek_record == 0 && !(conversions_mask & C_NOTRUNC)) omode |= O_TRUNC; @@ -382,6 +398,11 @@ else output_file = _("standard output"); +#ifdef OS2 + setmode (input_fd, O_BINARY); + setmode (output_fd, O_BINARY); +#endif + #ifdef _POSIX_VERSION sigaction (SIGINT, NULL, &sigact); if (sigact.sa_handler != SIG_IGN) @@ -608,8 +629,13 @@ } } else + { r_full++; + if (echo_progress) + fprintf (stderr, "\r%d ", r_full); + } + if (ibuf == obuf) /* If not C_TWOBUFS. */ { int nwritten = full_write (output_fd, obuf, nread); @@ -838,6 +864,10 @@ input_file = val; else if (equal (name, "of")) output_file = val; + else if (equal (name, "echo")) + echo_progress = equal (val, "on"); + else if (equal (name, "logdisk")) + use_logical = equal (val, "on"); else if (equal (name, "conv")) parse_conversion (val); else @@ -1036,6 +1066,7 @@ static void print_stats (void) { + fputs ("\r", stderr); fprintf (stderr, _("%u+%u records in\n"), r_full, r_partial); fprintf (stderr, _("%u+%u records out\n"), w_full, w_partial); if (r_truncate > 0) @@ -1082,6 +1113,7 @@ static void usage (int status) { + print_version("dd"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); @@ -1117,6 +1149,16 @@ swab swap every pair of input bytes\n\ noerror continue after read errors\n\ sync pad every input block with NULs to ibs-size\n")); +#ifdef OS2 + printf (_("\n\ +OS/2 specific options/parameters:\n\n\ + echo=on display progress by counting blocks on stdout\n\ + logdisk=on on floppy drives, use logical drive parameters\n\ +\n\ + FILE can also be a logical drive name, such as A: or B: or a\n\ + physical hard disk name, such as $1: or $2: and so on.\n\ + ")); +#endif } exit (status); } diff -Nur fileutils-3.13.org/src/df.c fileutils-3.13/src/df.c --- fileutils-3.13.org/src/df.c Wed Jun 19 04:20:22 1996 +++ fileutils-3.13/src/df.c Fri Aug 2 09:15:10 1996 @@ -140,7 +140,11 @@ printf (" "); if (inode_format) +#ifdef OS2 + printf (" Type "); +#else printf (" Inodes IUsed IFree %%IUsed"); +#endif else if (megabyte_blocks) printf (" MB-blocks Used Available Capacity"); @@ -213,7 +217,11 @@ if (fs_select_list == NULL || fstype == NULL) return 1; for (fsp = fs_select_list; fsp; fsp = fsp->fs_next) +#ifdef OS2 + if (strstr (fstype, fsp->fs_name)) +#else if (STREQ (fstype, fsp->fs_name)) +#endif return 1; return 0; } @@ -310,8 +318,12 @@ printf (" %-5s ", fstype); if (inode_format) +#ifdef OS2 + printf ("%-23.23s", fstype); +#else printf (" %7ld %7ld %7ld %5ld%%", fsu.fsu_files, inodes_used, fsu.fsu_ffree, inodes_percent_used); +#endif else if (human_blocks) { char buf[3][LONGEST_HUMAN_READABLE_1K_BYTE_BLOCKS + 1]; @@ -353,7 +365,11 @@ struct mount_entry *me; for (me = mount_list; me; me = me->me_next) +#ifdef OS2 + if (STREQ (disk, me->me_mountdir)) +#else if (STREQ (disk, me->me_devname)) +#endif { show_dev (me->me_devname, me->me_mountdir, me->me_type); return; @@ -362,6 +378,8 @@ show_dev (disk, (char *) NULL, (char *) NULL); } +#ifndef OS2 + /* Figure out which device file or directory POINT is mounted on and show its disk usage. STATP is the results of `stat' on POINT. */ @@ -401,16 +419,26 @@ exit_status = 1; } +#endif + /* Determine what kind of node PATH is and show the disk usage for it. STATP is the results of `stat' on PATH. */ static void show_entry (const char *path, const struct stat *statp) { +#ifdef OS2 + char name[3]; + name[0] = statp->st_dev; + name[1] = ':'; + name[2] = 0; + show_disk (name); +#else if (S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode)) show_disk (path); else show_point (path, statp); +#endif } /* Show all mounted filesystems, except perhaps those that are of @@ -454,6 +482,7 @@ static void usage (int status) { + print_version("df"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); @@ -514,7 +543,7 @@ posix_format = 0; exit_status = 0; - while ((i = getopt_long (argc, argv, "aihkmPTt:vx:", long_options, NULL)) + while ((i = getopt_long (argc, argv, "aihkmPTt:vx:?", long_options, NULL)) != EOF) { switch (i) @@ -522,7 +551,11 @@ case 0: /* Long option. */ break; case 'a': +#ifdef OS2 + show_all_fs = 3; +#else show_all_fs = 1; +#endif break; case 'i': inode_format = 1; @@ -564,7 +597,7 @@ add_excluded_fs_type (optarg); break; default: - usage (1); + usage (0); } } @@ -618,12 +651,26 @@ } else { +#ifdef OS2 + char path[256]; +#endif /* stat all the given entries to make sure they get automounted, if necessary, before reading the filesystem table. */ stats = (struct stat *) xmalloc ((argc - optind) * sizeof (struct stat)); for (i = optind; i < argc; ++i) +#ifdef OS2 + if (_fullpath(path, argv[i], sizeof(path)) == 0) + { + path[0] = toupper(path[0]); + stats[i - optind].st_dev = path[0]; + if (path[0] < 'C') + show_all_fs |= path[0] - '@'; + } + else +#else if (stat (argv[i], &stats[i - optind])) +#endif { error (0, errno, "%s", argv[i]); exit_status = 1; diff -Nur fileutils-3.13.org/src/dircolors.c fileutils-3.13/src/dircolors.c --- fileutils-3.13.org/src/dircolors.c Wed Jul 10 03:50:14 1996 +++ fileutils-3.13/src/dircolors.c Fri Aug 2 11:09:06 1996 @@ -47,6 +47,9 @@ { SHELL_SYNTAX_BOURNE, SHELL_SYNTAX_C, +#ifdef OS2 + SHELL_SYNTAX_OS2, +#endif SHELL_SYNTAX_UNKNOWN }; @@ -88,6 +91,10 @@ {"csh", no_argument, NULL, 'c'}, {"c-shell", no_argument, NULL, 'c'}, {"help", no_argument, NULL, 'h'}, +#ifdef OS2 + {"os2", no_argument, NULL, 'o'}, + {"os2-shell", no_argument, NULL, 'o'}, +#endif {"print-data-base", no_argument, NULL, 'p'}, {"print-database", no_argument, NULL, 'p'}, {"version", no_argument, NULL, 'v'}, @@ -98,6 +105,7 @@ static void usage (int status) { + print_version("dircolors"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); @@ -114,6 +122,10 @@ -h, --help display this help and exit\n\ --version output version information and exit\n\ ")); +#ifdef OS2 + printf (_("\ + -o, --os2, --os2-shell output OS/2 cmd.exe code to set LS_COLOR\n")); +#endif } exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); @@ -137,6 +149,17 @@ char *shell; shell = getenv ("SHELL"); +#ifdef OS2 + if (shell == NULL) + shell = getenv ("OS2_SHELL"); + if (shell == NULL) + shell = getenv ("COMSPEC"); + shell = strcpy (alloca (strlen (shell) + 1), shell); + strlwr (shell); + if (STREQ (shell + strlen (shell) - 4, ".exe")) + shell[strlen (shell) - 4] = 0; +#endif + if (shell == NULL || *shell == '\0') return SHELL_SYNTAX_UNKNOWN; @@ -145,6 +168,11 @@ if (STREQ (shell, "csh") || STREQ (shell, "tcsh")) return SHELL_SYNTAX_C; +#ifdef OS2 + if (STREQ (shell, "cmd") || STREQ (shell, "4os2")) + return SHELL_SYNTAX_OS2; +#endif + return SHELL_SYNTAX_BOURNE; } @@ -419,7 +447,7 @@ parse_long_options (argc, argv, "dircolors", PACKAGE_VERSION, usage); - while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL)) + while ((optc = getopt_long (argc, argv, "bcop?", long_options, NULL)) != EOF) switch (optc) { @@ -431,12 +459,18 @@ syntax = SHELL_SYNTAX_C; break; +#ifdef OS2 + case 'o': /* OS/2 shell syntax. */ + syntax = SHELL_SYNTAX_OS2; + break; +#endif + case 'p': print_database = 1; break; default: - usage (1); + usage (0); } argc -= optind; @@ -501,6 +535,14 @@ const char *prefix; const char *suffix; +#ifdef OS2 + if (syntax == SHELL_SYNTAX_OS2) + { + prefix = "set LS_COLORS=\""; + suffix = "\"\n"; + } + else +#endif if (syntax == SHELL_SYNTAX_BOURNE) { prefix = "LS_COLORS='"; diff -Nur fileutils-3.13.org/src/dircolors.h fileutils-3.13/src/dircolors.h --- fileutils-3.13.org/src/dircolors.h Tue Jul 9 04:39:56 1996 +++ fileutils-3.13/src/dircolors.h Fri Aug 2 11:03:46 1996 @@ -1,11 +1,12 @@ -#define G_N_LINES 72 +#define G_N_LINES 74 const size_t G_line_length[G_N_LINES] = { 65, 72, 0, 59, 61, 0, 77, 10, 12, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, - 10, 10, 0, 73, 64, 18, 64, 19, 72, 25, 72, 68, 22, 22, 27, 17, 19, 34, - 39, 0, 44, 10, 0, 70, 75, 48, 39, 10, 10, 10, 10, 48, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 26, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9 + 10, 10, 9, 11, 0, 73, 64, 18, 64, 19, 72, 25, 72, 68, 22, 22, 27, 17, + 19, 34, 39, 0, 44, 10, 0, 70, 75, 48, 39, 10, 10, 10, 10, 48, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 26, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, + 9 }; const char *const G_line[G_N_LINES] = @@ -31,6 +32,8 @@ "TERM con80x60", "TERM xterm", "TERM vt100", + "TERM ansi", + "TERM window", "", "# Below are the color init strings for the basic file types. A color init", "# string consists of one or more of the following numeric codes:", diff -Nur fileutils-3.13.org/src/dircolors.hin fileutils-3.13/src/dircolors.hin --- fileutils-3.13.org/src/dircolors.hin Tue Jul 9 03:07:20 1996 +++ fileutils-3.13/src/dircolors.hin Fri Aug 2 11:01:52 1996 @@ -19,6 +19,8 @@ TERM con80x60 TERM xterm TERM vt100 +TERM ansi +TERM window # Below are the color init strings for the basic file types. A color init # string consists of one or more of the following numeric codes: diff -Nur fileutils-3.13.org/src/du.c fileutils-3.13/src/du.c --- fileutils-3.13.org/src/du.c Wed Apr 24 04:55:20 1996 +++ fileutils-3.13/src/du.c Fri Aug 2 10:21:02 1996 @@ -207,6 +207,7 @@ static void usage (int status, char *reason) { + print_version("du"); if (reason != NULL) fprintf (status == 0 ? stdout : stderr, "%s: %s\n", program_name, reason); @@ -266,7 +267,7 @@ else output_size = size_kilobytes; - while ((c = getopt_long (argc, argv, "abchklmsxDLS", long_options, + while ((c = getopt_long (argc, argv, "abchklmsxDLS?", long_options, (int *) 0)) != EOF) { @@ -328,7 +329,7 @@ break; default: - usage (2, (char *) 0); + usage (0, (char *) 0); } } @@ -436,6 +437,9 @@ int s; arg = files[i]; +#ifdef OS2 + UnixFileName(arg); +#endif /* Delete final slash in the argument, unless the slash is alone. */ s = strlen (arg) - 1; @@ -504,10 +508,12 @@ return 0; } +#ifndef OS2 if (!opt_count_all && stat_buf.st_nlink > 1 && hash_insert (stat_buf.st_ino, stat_buf.st_dev)) return 0; /* Have counted this already. */ +#endif if (output_size == size_bytes) size = stat_buf.st_size; @@ -523,7 +529,7 @@ char *name_space; char *namep; struct saved_cwd cwd; - int through_symlink; + int through_symlink = 0; struct stat e_buf; dir_dev = stat_buf.st_dev; @@ -537,9 +543,11 @@ /* If we're dereferencing symlinks and we're about to chdir through a symlink, remember the current directory so we can return to it later. In other cases, chdir ("..") works fine. */ +#ifdef S_ISLNK through_symlink = (xstat == stat && lstat (ent, &e_buf) == 0 && S_ISLNK (e_buf.st_mode)); +#endif if (through_symlink) if (save_cwd (&cwd)) exit (1); @@ -564,7 +572,7 @@ exit (1); free_cwd (&cwd); } - else if (chdir ("..") < 0) + else if (chdir ("..") < 0 && errno != ENOENT) error (1, errno, _("cannot change to `..' from directory %s"), path->text); exit_status = 1; @@ -595,7 +603,7 @@ restore_cwd (&cwd, "..", path->text); free_cwd (&cwd); } - else if (chdir ("..") < 0) + else if (chdir ("..") < 0 && errno != ENOENT) error (1, errno, _("cannot change to `..' from directory %s"), path->text); diff -Nur fileutils-3.13.org/src/fu.def fileutils-3.13/src/fu.def --- fileutils-3.13.org/src/fu.def Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/src/fu.def Wed May 5 11:34:12 2004 @@ -0,0 +1,3 @@ +NAME WINDOWCOMPAT NEWFILES +DESCRIPTION 'GNU file utilities' +STACKSIZE 0x80000 diff -Nur fileutils-3.13.org/src/install.c fileutils-3.13/src/install.c --- fileutils-3.13.org/src/install.c Wed Jul 10 01:19:12 1996 +++ fileutils-3.13/src/install.c Fri Aug 2 09:18:18 1996 @@ -58,6 +58,9 @@ #include #include #include +#ifdef OS2 +#include +#endif #include "system.h" #include "backupfile.h" @@ -257,8 +260,12 @@ if (optind == argc || (optind == argc - 1 && !dir_arg)) { +#ifdef OS2 + usage (0); +#else error (0, 0, _("too few arguments")); usage (1); +#endif } if (symbolic_mode) @@ -411,7 +418,7 @@ target_created = 0; } - fromfd = open (from, O_RDONLY, 0); + fromfd = open (from, O_RDONLY | O_BINARY, 0); if (fromfd == -1) { error (0, errno, "%s", from); @@ -419,7 +426,7 @@ } /* Make sure to open the file in a mode that allows writing. */ - tofd = open (to, O_WRONLY | O_CREAT | O_TRUNC, 0600); + tofd = open (to, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600); if (tofd == -1) { error (0, errno, "%s", to); @@ -452,6 +459,11 @@ } if (ret == 0) *to_created = target_created; + +#ifdef OS2 + CopyEAs(from, to); +#endif + return ret; copy_error: @@ -510,6 +522,9 @@ static void strip (char *path) { +#ifdef OS2 + spawnlp (P_WAIT, "strip", "strip", path, (char *) NULL); +#else int pid, status; pid = fork (); @@ -528,6 +543,7 @@ /* Do nothing. */ ; break; } +#endif } /* Initialize the user and group ownership of the files to install. */ @@ -535,6 +551,7 @@ static void get_ids (void) { +#ifndef OS2 struct passwd *pw; struct group *gr; @@ -573,11 +590,13 @@ } else group_id = getgid (); +#endif } static void usage (int status) { + print_version("install"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); diff -Nur fileutils-3.13.org/src/ls.c fileutils-3.13/src/ls.c --- fileutils-3.13.org/src/ls.c Mon Jul 8 04:23:46 1996 +++ fileutils-3.13/src/ls.c Tue Mar 31 07:22:22 1998 @@ -49,8 +49,10 @@ #endif #include +#ifndef OS2 #include #include +#endif #include #if HAVE_LIMITS_H @@ -490,6 +492,12 @@ /* If nonzero, print the version on standard output and exit. */ static int show_version; +#ifdef OS2 +/* if non-zero, print plain Unix long format, otherwise + a format somewhat tailored for OS/2. */ +static int unix_mode; +#endif + static struct option const long_options[] = { {"all", no_argument, 0, 'a'}, @@ -518,6 +526,9 @@ {"sort", required_argument, 0, 10}, {"tabsize", required_argument, 0, 'T'}, {"time", required_argument, 0, 11}, +#ifdef OS2 + {"unix", no_argument, &unix_mode, 1}, +#endif {"help", no_argument, &show_help, 1}, {"version", no_argument, &show_version, 1}, {"color", optional_argument, 0, 13}, @@ -694,8 +705,36 @@ if (i < argc) dir_defaulted = 0; + +#ifdef OS2 + for (; i < argc; i++) + { + int len = strlen(argv[i]); + + if ((argv[i][len - 1] == '/' || argv[i][len - 1] == '\\') + && !(len == 1) && !(len == 3 && argv[i][1] == ':')) + { + argv[i][len - 1] = 0; + len--; + } + + if (len == 2 && argv[i][1] == ':') + { + /* The user wants the cwd on another drive. Help + by appending a `.' to it. (This allows to stat() + the directory.) */ + char *temp = (char *) xmalloc (4); + strcpy (temp, argv[i]); + strcat (temp, "."); + argv[i] = temp; + } + + gobble_file (argv[i], 1, ""); + } +#else /* not OS2 */ for (; i < argc; i++) gobble_file (argv[i], 1, ""); +#endif /* not OS2 */ if (dir_defaulted) { @@ -852,7 +891,7 @@ } while ((c = getopt_long (argc, argv, - "abcdfgiklmnopqrstuw:xABCDFGI:LNQRST:UX1", + "abcdfgiklmnopqrstuw:xABCDFGI:LNQRST:UX1?", long_options, (int *) 0)) != EOF) { switch (c) @@ -1089,7 +1128,7 @@ break; default: - usage (1); + usage (0); } } @@ -1134,6 +1173,7 @@ switch (*p) { case ':': + case '"': case '\0': state = ST_END; /* End of string */ break; @@ -1332,6 +1372,7 @@ case 1: /* First label character */ switch (*p) { + case '"': case ':': ++p; break; @@ -1544,13 +1585,22 @@ if (fnmatch (ignore->pattern, next->d_name, FNM_PERIOD) == 0) return 0; +#ifdef OS2 + if (really_all_files + || (next->d_name[0] != '.' && !(next->d_attr & (A_SYSTEM | A_HIDDEN)) ) + || (all_files + && next->d_name[1] != '\0' + && (next->d_name[1] != '.' || next->d_name[2] != '\0') + && !(next->d_attr & A_SYSTEM))) + return 1; +#else if (really_all_files || next->d_name[0] != '.' || (all_files && next->d_name[1] != '\0' && (next->d_name[1] != '.' || next->d_name[2] != '\0'))) return 1; - +#endif return 0; } @@ -1594,11 +1644,13 @@ files[files_index].linkname = 0; files[files_index].linkmode = 0; - if (explicit_arg || format_needs_stat) - { /* `path' is the absolute pathname of this file. */ +#ifdef OS2 + if (name[0] == '/' || name[0] == '\\' || dirname[0] == 0) +#else if (name[0] == '/' || dirname[0] == 0) +#endif path = (char *) name; else { @@ -1606,6 +1658,8 @@ attach (path, dirname, name); } + if (explicit_arg || format_needs_stat) + { if (trace_links) { val = stat (path, &files[files_index].stat); @@ -1618,6 +1672,8 @@ val = lstat (path, &files[files_index].stat); if (val < 0) { + if (strcmp(name, "..") == 0) + return 0; error (0, errno, "%s", path); exit_status = 1; return 0; @@ -1779,7 +1835,11 @@ if ((files[i].filetype == directory || files[i].filetype == arg_directory) && (!recursive || is_not_dot_or_dotdot (files[i].name))) { +#ifdef OS2 + if (files[i].name[0] == '/' || files[i].name[0] == '\\' || dirname[0] == 0) +#else if (files[i].name[0] == '/' || dirname[0] == 0) +#endif { queue_directory (files[i].name, files[i].linkname); } @@ -2041,7 +2101,7 @@ break; } - strcpy (timebuf, ctime (&when)); + strcpy (timebuf, when > 0 ? ctime (&when) : " invalid date"); if (full_time) timebuf[24] = '\0'; @@ -2079,12 +2139,20 @@ /* The space between the mode and the number of links is the POSIX "optional alternate access method flag". */ +#ifdef OS2 + if (!unix_mode) + sprintf (p, "%-7.7s%-3.3s ", modebuf, modestring(f->stat.st_attr)); + else +#endif sprintf (p, "%s %3u ", modebuf, (unsigned int) f->stat.st_nlink); p += strlen (p); if (numeric_users) sprintf (p, "%-8u ", (unsigned int) f->stat.st_uid); else +#ifdef OS2 + if (unix_mode) +#endif sprintf (p, "%-8.8s ", getuser (f->stat.st_uid)); p += strlen (p); @@ -2093,11 +2161,18 @@ if (numeric_users) sprintf (p, "%-8u ", (unsigned int) f->stat.st_gid); else +#ifdef OS2 + if (unix_mode) +#endif sprintf (p, "%-8.8s ", getgroup (f->stat.st_gid)); p += strlen (p); } +#ifdef S_ISBLK if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode)) +#else + if (S_ISCHR (f->stat.st_mode)) +#endif sprintf (p, "%3u, %3u ", (unsigned) major (f->stat.st_rdev), (unsigned) minor (f->stat.st_rdev)); else @@ -2668,7 +2743,11 @@ while (*dirnamep) *dest++ = *dirnamep++; /* Add '/' if `dirname' doesn't already end with it. */ +#ifdef OS2 + if (dirnamep > dirname && dirnamep[-1] != '/' && dirnamep[-1] != '\\') +#else if (dirnamep > dirname && dirnamep[-1] != '/') +#endif *dest++ = '/'; } while (*name) @@ -2679,6 +2758,13 @@ static void usage (int status) { + if (ls_mode == LS_LONG_FORMAT) + print_version("vdir"); + else if (ls_mode == LS_MULTI_COL) + print_version("dir"); + else + print_version("ls"); + if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); diff -Nur fileutils-3.13.org/src/Makefile.os2 fileutils-3.13/src/Makefile.os2 --- fileutils-3.13.org/src/Makefile.os2 Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/src/Makefile.os2 Wed May 5 11:34:12 2004 @@ -0,0 +1,108 @@ +# Makefile for GNU fileutils programs. +# Do not use this makefile directly, but only from `../Makefile'. +# Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc. + +PROGS = chmod.exe cp.exe dd.exe dircolors.exe du.exe install.exe \ +mkdir.exe mv.exe rm.exe rmdir.exe touch.exe df.exe ls.exe dir.exe vdir.exe + +.SUFFIXES: .c $O + +.c$O: + $(CC) $(CFLAGS) -c $< + +.PHONY: all +all: $(PROGS) + +$(PROGS): os2main$O fu.def $(LIBS) + +chmod.exe: chmod$O + $(CC) chmod$O $(LDFLAGS) -o $@ $(LIBS) + +chgrp.exe: chgrp$O + $(CC) chgrp$O $(LDFLAGS) -o $@ $(LIBS) + +chown.exe: chown$O + $(CC) chown$O $(LDFLAGS) -o $@ $(LIBS) + +cp.exe: cp$O cp-hash$O cp-aux$O + $(CC) cp$O cp-hash$O cp-aux$O $(LDFLAGS) -o $@ $(LIBS) + +dd.exe: dd$O + $(CC) dd$O $(LDFLAGS) -o $@ $(LIBS) + +dircolors.exe: dircolors$O + $(CC) dircolors$O $(LDFLAGS) -o $@ $(LIBS) + +df.exe: df$O + $(CC) df$O $(LDFLAGS) -o $@ $(LIBS) + +dir.exe: ls$O ls-dir$O + $(CC) ls$O ls-dir$O $(LDFLAGS) -o $@ $(LIBS) + +du.exe: du$O + $(CC) du$O $(LDFLAGS) -o $@ $(LIBS) + +install.exe: install$O + $(CC) install$O $(LDFLAGS) -o $@ $(LIBS) + +ln.exe: ln$O + $(CC) ln$O $(LDFLAGS) -o $@ $(LIBS) + +ls.exe: ls$O ls-ls$O + $(CC) ls$O ls-ls$O $(LDFLAGS) -o $@ $(LIBS) + +mkdir.exe: mkdir$O + $(CC) mkdir$O $(LDFLAGS) -o $@ $(LIBS) + +mkfifo.exe: mkfifo$O + $(CC) mkfifo$O $(LDFLAGS) -o $@ $(LIBS) + +mknod.exe: mknod$O + $(CC) mknod$O $(LDFLAGS) -o $@ $(LIBS) + +mv.exe: mv$O + $(CC) mv$O $(LDFLAGS) -o $@ $(LIBS) + +mvdir.exe: mvdir$O + $(CC) mvdir$O $(LDFLAGS) -o $@ $(LIBS) + +rm.exe: rm$O + $(CC) rm$O $(LDFLAGS) -o $@ $(LIBS) + +rmdir.exe: rmdir$O + $(CC) rmdir$O $(LDFLAGS) -o $@ $(LIBS) + +touch.exe: touch$O + $(CC) touch$O $(LDFLAGS) -o $@ $(LIBS) + +vdir.exe: ls$O ls-vdir$O + $(CC) ls$O ls-vdir$O $(LDFLAGS) -o $@ $(LIBS) + +# Compilation rules. + +chgrp$O: chgrp.c system.h ../lib/pathmax.h ../lib/xstrtoul.h ../lib/xstrtol.h ../lib/error.h +chmod$O: chmod.c ../lib/modechange.h system.h ../lib/pathmax.h ../lib/error.h +chown$O: chown.c system.h ../lib/pathmax.h ../lib/error.h +cp-aux$O: cp-aux.c cp.h system.h ../lib/pathmax.h ../lib/error.h +cp-hash$O: cp-hash.c cp.h system.h ../lib/pathmax.h ../lib/error.h +cp$O: cp.c cp.h system.h ../lib/pathmax.h ../lib/error.h ../lib/backupfile.h ../lib/argmatch.h +dd$O: dd.c system.h ../lib/pathmax.h ../lib/error.h +df$O: df.c ../lib/mountlist.h ../lib/fsusage.h system.h ../lib/pathmax.h ../lib/error.h +dircolors$O: dircolors.c system.h ../lib/pathmax.h ../lib/getline.h ../lib/long-options.h ../lib/error.h ../lib/obstack.h dircolors.h +du$O: du.c system.h ../lib/pathmax.h ../lib/save-cwd.h ../lib/error.h +install$O: install.c system.h ../lib/pathmax.h ../lib/backupfile.h ../lib/modechange.h ../lib/makepath.h ../lib/error.h ../lib/xstrtol.h +ln$O: ln.c system.h ../lib/pathmax.h ../lib/backupfile.h ../lib/error.h +ls$O: ls.c system.h ../lib/pathmax.h ../lib/obstack.h ls.h ../lib/error.h ../lib/argmatch.h ../lib/xstrtol.h +ls-dir$O ls-ls$O ls-vdir$O: ls.h +mkdir$O: mkdir.c system.h ../lib/pathmax.h ../lib/modechange.h ../lib/makepath.h ../lib/error.h +mkfifo$O: mkfifo.c system.h ../lib/pathmax.h ../lib/modechange.h ../lib/error.h +mknod$O: mknod.c system.h ../lib/pathmax.h ../lib/modechange.h ../lib/error.h ../lib/xstrtol.h +mv$O: mv.c system.h ../lib/pathmax.h ../lib/backupfile.h ../lib/error.h +mvdir$O: mvdir.c system.h ../lib/pathmax.h ../lib/save-cwd.h ../lib/error.h +rm$O: rm.c system.h ../lib/pathmax.h ../lib/error.h +rmdir$O: rmdir.c system.h ../lib/pathmax.h ../lib/error.h +sync$O: sync.c system.h ../lib/pathmax.h ../lib/long-options.h ../lib/error.h +touch$O: touch.c system.h ../lib/pathmax.h ../lib/error.h ../lib/argmatch.h + +clean: + rm -f *.o *.obj diff -Nur fileutils-3.13.org/src/mkdir.c fileutils-3.13/src/mkdir.c --- fileutils-3.13.org/src/mkdir.c Thu Apr 25 03:04:18 1996 +++ fileutils-3.13/src/mkdir.c Fri Aug 2 09:22:16 1996 @@ -62,6 +62,7 @@ static void usage (int status) { + print_version("mkdir"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); @@ -128,8 +129,12 @@ if (optind == argc) { +#ifdef OS2 + usage (0); +#else error (0, 0, _("too few arguments")); usage (1); +#endif } newmode = 0777 & ~umask (0); @@ -146,6 +151,9 @@ for (; optind < argc; ++optind) { +#ifdef OS2 + UnixFileName (argv[optind]); +#endif if (path_mode) { errors |= make_path (argv[optind], newmode, parent_mode, diff -Nur fileutils-3.13.org/src/mv.c fileutils-3.13/src/mv.c --- fileutils-3.13.org/src/mv.c Sat Jul 6 22:35:08 1996 +++ fileutils-3.13/src/mv.c Fri Aug 2 09:30:52 1996 @@ -148,13 +148,13 @@ return 1; } - ifd = open (source, O_RDONLY, 0); + ifd = open (source, O_RDONLY | O_BINARY, 0); if (ifd < 0) { error (0, errno, "%s", source); return 1; } - ofd = open (dest, O_WRONLY | O_CREAT | O_TRUNC, 0600); + ofd = open (dest, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600); if (ofd < 0) { error (0, errno, "%s", dest); @@ -197,6 +197,10 @@ /* chown turns off set[ug]id bits for non-root, so do the chmod last. */ +#ifdef OS2 + CopyEAs(source, dest); +#endif + /* Try to copy the old file's modtime and access time. */ { struct utimbuf tv; @@ -219,7 +223,12 @@ return 1; } +#ifdef OS2 + if (chmod (dest, source_stats.st_mode & 07777) || + setfmode(dest, getfmode(source))) +#else if (chmod (dest, source_stats.st_mode & 07777)) +#endif { error (0, errno, "%s", dest); return 1; @@ -245,8 +254,15 @@ if (lstat (dest, &dest_stats) == 0) { +#ifdef OS2 + char f_dest[PATH_MAX], f_source[PATH_MAX]; + _abspath(f_dest, dest, PATH_MAX); + _abspath(f_source, source, PATH_MAX); + if (_fncmp (f_source, f_dest) == 0) +#else if (source_stats.st_dev == dest_stats.st_dev && source_stats.st_ino == dest_stats.st_ino) +#endif { error (0, 0, _("`%s' and `%s' are the same file"), source, dest); return 1; @@ -370,6 +386,7 @@ static void usage (int status) { + print_version("mv"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); @@ -411,7 +428,7 @@ int c; int errors; int make_backups = 0; - char *version; + char *version, *target; program_name = argv[0]; setlocale (LC_ALL, ""); @@ -471,6 +488,11 @@ if (show_help) usage (0); +#ifdef OS2 + if (argc == optind) + usage (0); +#endif + if (argc < optind + 2) { error (0, 0, "%s", (argc == optind @@ -488,9 +510,15 @@ error (1, 0, _("when moving multiple files, last argument must be a directory")); + target = argv[argc - 1]; +#ifdef OS2 + target = fix_colon(target); + UnixFileName(target); +#endif + /* Move each arg but the last onto the last. */ for (; optind < argc - 1; ++optind) - errors |= movefile (argv[optind], argv[argc - 1]); + errors |= movefile (argv[optind], target); exit (errors); } diff -Nur fileutils-3.13.org/src/os2main.c fileutils-3.13/src/os2main.c --- fileutils-3.13.org/src/os2main.c Thu Jan 1 00:00:00 1970 +++ fileutils-3.13/src/os2main.c Fri Aug 2 10:06:08 1996 @@ -0,0 +1,13 @@ +#include + +int main(int argc, char **argv) +{ +#ifdef __EMX__ + _response(&argc, &argv); + _wildcard(&argc, &argv); + _nls_init(); +#endif + set_program_name(argv[0]); + setvbuf(stdout, NULL, _IOLBF, BUFSIZ); + return os2main(argc, argv); +} diff -Nur fileutils-3.13.org/src/rm.c fileutils-3.13/src/rm.c --- fileutils-3.13.org/src/rm.c Wed Apr 24 04:41:00 1996 +++ fileutils-3.13/src/rm.c Fri Aug 2 09:24:58 1996 @@ -170,8 +170,12 @@ exit (0); else { +#ifdef OS2 + usage (0); +#else error (0, 0, _("too few arguments")); usage (1); +#endif } } @@ -221,7 +225,11 @@ set errno to ENOENT. */ || (pathname[0] == '\0' && (errno = ENOENT))) { +#ifdef __EMX__ + if ((errno == ENOENT || errno == EINVAL )&& ignore_missing_files) +#else if (errno == ENOENT && ignore_missing_files) +#endif return 0; error (0, errno, "%s", pathname); return 1; @@ -359,17 +367,31 @@ int err = 0; /* Return status. */ struct pathstack pathframe; /* New top of stack. */ struct pathstack *pp; /* Temporary. */ + int count, lastcount; + +#ifdef OS2 /* stat () it ourselves ... */ + if ( (dirp = opendir (pathname)) ) + { + statp->st_size = 0L; + for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp)) + statp->st_size += sizeof (ino_t); + closedir (dirp); + } +#endif name_size = statp->st_size; name_space = (char *) xmalloc (name_size); n_inodes_allocated = (statp->st_size + sizeof (ino_t) - 1) / sizeof (ino_t); inode_space = (ino_t *) xmalloc (n_inodes_allocated * sizeof (ino_t)); + count = 0; do { namep = name_space; inodep = inode_space; + lastcount = count; + count = 0; errno = 0; dirp = opendir (pathname); @@ -406,6 +428,7 @@ name_space = new_name_space; } namep = stpcpy (namep, dp->d_name) + 1; + count++; if (inodep == inode_space + n_inodes_allocated) { @@ -471,7 +494,7 @@ } } /* Keep trying while there are still files to remove. */ - while (namep > name_space && err == 0); + while (namep > name_space && err == 0 && count != lastcount); free (name_space); free (inode_space); @@ -488,6 +511,7 @@ static int duplicate_entry (struct pathstack *stack, ino_t inum) { +#ifndef OS2 #ifdef D_INO_IN_DIRENT struct pathstack *p; @@ -517,12 +541,14 @@ } } #endif /* D_INO_IN_DIRENT */ +#endif return 0; } static void usage (int status) { + print_version("rm"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); diff -Nur fileutils-3.13.org/src/rmdir.c fileutils-3.13/src/rmdir.c --- fileutils-3.13.org/src/rmdir.c Wed Apr 24 04:41:00 1996 +++ fileutils-3.13/src/rmdir.c Fri Aug 2 09:23:00 1996 @@ -78,6 +78,7 @@ static void usage (int status) { + print_version("rmdir"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); @@ -132,8 +133,12 @@ if (optind == argc) { +#ifdef OS2 + usage (0); +#else error (0, 0, _("too few arguments")); usage (1); +#endif } for (; optind < argc; ++optind) diff -Nur fileutils-3.13.org/src/system.h fileutils-3.13/src/system.h --- fileutils-3.13.org/src/system.h Wed Jul 3 03:59:48 1996 +++ fileutils-3.13/src/system.h Fri Aug 2 11:31:30 1996 @@ -296,6 +296,22 @@ #include +#ifdef __EMX__ +#undef islower +#undef isupper +#undef tolower +#undef toupper +#define islower(c) IsLower(c) +#define isupper(c) IsUpper(c) +#define tolower(c) ToLower(c) +#define toupper(c) ToUpper(c) +#define ispcchar(c) (0x80 <= (c) && (c) <= 0xFe) +#undef isprint +#undef isgraph +#define isprint(c) (isprint(c) || ispcchar(c)) +#define isgraph(c) (isgraph(c) || ispcchar(c)) +#endif + #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) #define IN_CTYPE_DOMAIN(c) 1 #else @@ -342,7 +358,7 @@ #endif #if ENABLE_NLS -# include +# include # define _(Text) gettext (Text) #else # define bindtextdomain(Domain, Directory) /* empty */ @@ -351,3 +367,21 @@ #endif #define STREQ(a,b) (strcmp((a), (b)) == 0) + +#define print_version(x) \ + fprintf(stderr, "\n%s - %s\n\n", PACKAGE_VERSION, x) + +#ifdef OS2 +#include +#define geteuid() 1 +#define getegid() 1 +#define rename(from, to) ((access(to, 0) ? 0 : unlink(to)) || rename(from, to)) +#define unlink(f) (chmod(f, 0666), unlink(f)) +#define link(a, b) (-1) +#define sync() 0 +#define chdir(d) _chdir2(d) +#define getcwd(b, s) _getcwd2(b, s) +#define lstat stat +#define main(c, v) os2main(c, v) +extern char *fix_colon(char *); +#endif diff -Nur fileutils-3.13.org/src/touch.c fileutils-3.13/src/touch.c --- fileutils-3.13.org/src/touch.c Wed Apr 24 04:39:58 1996 +++ fileutils-3.13/src/touch.c Fri Aug 2 09:23:28 1996 @@ -240,6 +240,7 @@ static void usage (int status) { + print_version("touch"); if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); @@ -384,8 +385,12 @@ if (optind == argc) { +#ifdef OS2 + usage (0); +#else error (0, 0, _("file arguments missing")); usage (1); +#endif } for (; optind < argc; ++optind)