Only in new: README.OS2 Only in new: patches.os2 Only in new: Makefile Only in new: config.h Only in new/lib: Makefile Only in new/lib: gnufu.def Only in new/lib: diskacc.c Only in new/lib: diskacc.h Only in new/lib: disktape.c Only in new/lib: disktape.h Only in new/lib: dllmain.c Only in new/lib: os2ea.c Only in new/src: Makefile Only in new/src: gnufile.def diff -cbr orig/lib/basename.c new/lib/basename.c *** orig/lib/basename.c Tue Oct 12 16:17:46 1993 --- new/lib/basename.c Mon Oct 25 20:57:32 1993 *************** *** 44,48 **** --- 44,52 ---- char *base; base = rindex (name, '/'); + #ifdef OS2 + if (base == NULL) + base = rindex (name, ':'); + #endif return base ? base + 1 : name; } diff -cbr orig/lib/eaccess.c new/lib/eaccess.c *** orig/lib/eaccess.c Tue Oct 12 16:17:54 1993 --- new/lib/eaccess.c Mon Oct 25 20:57:32 1993 *************** *** 35,40 **** --- 35,43 ---- #include #endif + #include "system.h" + + #ifndef OS2 #ifdef _POSIX_VERSION #include #if !defined(NGROUPS_MAX) || NGROUPS_MAX < 1 *************** *** 50,55 **** --- 53,59 ---- #define NGROUPS_MAX NGROUPS #endif /* not NGROUPS_MAX and NGROUPS */ #endif /* not POSIX_VERSION */ + #endif #include #ifndef STDC_HEADERS diff -cbr orig/lib/error.c new/lib/error.c *** orig/lib/error.c Tue Oct 05 21:01:52 1993 --- new/lib/error.c Mon Oct 25 20:57:32 1993 *************** *** 76,81 **** --- 76,92 ---- #define strerror private_strerror #endif /* !HAVE_STRERROR */ + #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 -cbr orig/lib/fnmatch.c new/lib/fnmatch.c *** orig/lib/fnmatch.c Tue Oct 12 16:18:06 1993 --- new/lib/fnmatch.c Mon Oct 25 20:57:34 1993 *************** *** 57,62 **** --- 57,66 ---- 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 -cbr orig/lib/fsusage.c new/lib/fsusage.c *** orig/lib/fsusage.c Tue Oct 12 16:18:08 1993 --- new/lib/fsusage.c Mon Oct 25 20:57:36 1993 *************** *** 68,73 **** --- 68,79 ---- int statvfs (); #endif + #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. */ *************** *** 183,194 **** --- 189,217 ---- adjust_blocks ((b), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512) #endif + #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 * fsalloc.cUnit / 512L; + fsp->fsu_bfree = cluster * fsalloc.cUnitAvail / 512L; + fsp->fsu_bavail = fsp->fsu_bfree; + fsp->fsu_files = 0; + fsp->fsu_ffree = 0; + #else + #if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ) /* !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); fsp->fsu_files = fsd.f_files; fsp->fsu_ffree = fsd.f_ffree; + #endif + #endif return 0; diff -cbr orig/lib/idcache.c new/lib/idcache.c *** orig/lib/idcache.c Tue Oct 12 16:18:18 1993 --- new/lib/idcache.c Mon Oct 25 20:57:38 1993 *************** *** 28,35 **** --- 28,37 ---- #include #include + #ifndef OS2 #include #include + #endif #if defined(STDC_HEADERS) || defined(HAVE_STRING_H) #include *************** *** 73,78 **** --- 75,83 ---- getuser (uid) uid_t uid; { + #ifdef OS2 + return "user"; + #else register struct userid *tail; struct passwd *pwent; char usernum_string[20]; *************** *** 96,101 **** --- 101,107 ---- tail->next = user_alist; user_alist = tail; return tail->name; + #endif } /* Translate USER to a UID, with cache. *************** *** 107,112 **** --- 113,122 ---- getuidbyname (user) char *user; { + #ifdef OS2 + static uid_t uid = 0; + return &uid; + #else register struct userid *tail; struct passwd *pwent; *************** *** 137,142 **** --- 147,153 ---- tail->next = nouser_alist; nouser_alist = tail; return 0; + #endif } /* Use the same struct as for userids. */ *************** *** 150,155 **** --- 161,169 ---- getgroup (gid) gid_t gid; { + #ifdef OS2 + return "group"; + #else register struct userid *tail; struct group *grent; char groupnum_string[20]; *************** *** 173,178 **** --- 187,193 ---- tail->next = group_alist; group_alist = tail; return tail->name; + #endif } /* Translate GROUP to a UID, with cache. *************** *** 184,189 **** --- 199,208 ---- getgidbyname (group) char *group; { + #ifdef OS2 + static gid_t gid = 0; + return &gid; + #else register struct userid *tail; struct group *grent; *************** *** 214,217 **** --- 233,237 ---- tail->next = nogroup_alist; nogroup_alist = tail; return 0; + #endif } diff -cbr orig/lib/makepath.c new/lib/makepath.c *** orig/lib/makepath.c Tue Oct 12 16:18:22 1993 --- new/lib/makepath.c Mon Oct 25 20:57:40 1993 *************** *** 86,91 **** --- 86,93 ---- typedef int gid_t; #endif + #include "system.h" + void error (); /* Ensure that the directory ARGPATH exists. diff -cbr orig/lib/modechange.c new/lib/modechange.c *** orig/lib/modechange.c Tue Oct 12 16:18:28 1993 --- new/lib/modechange.c Mon Oct 25 20:57:40 1993 *************** *** 108,115 **** --- 108,119 ---- return head; } + #ifdef OS2 + umask_value = 022; + #else umask_value = umask (0); umask (umask_value); /* Restore the old value. */ + #endif head = NULL; --mode_string; *************** *** 133,139 **** --- 137,147 ---- affected_bits |= 01007; break; case 'a': + #ifdef OS2 + affected_bits = 077777; + #else affected_bits |= 07777; + #endif break; default: goto no_more_affected; *************** *** 144,150 **** --- 152,162 ---- set in the umask. */ if (affected_bits == 0) { + #ifdef OS2 + affected_bits = 077777; + #else affected_bits = 07777; + #endif ops_to_mask = masked_ops; } *************** *** 199,206 **** --- 211,230 ---- 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; *************** *** 255,261 **** --- 279,289 ---- 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 -cbr orig/lib/mountlist.c new/lib/mountlist.c *** orig/lib/mountlist.c Tue Oct 12 16:18:30 1993 --- new/lib/mountlist.c Mon Oct 25 20:57:42 1993 *************** *** 52,57 **** --- 52,63 ---- # 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) *************** *** 426,431 **** --- 432,521 ---- 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 -cbr orig/lib/savedir.c new/lib/savedir.c *** orig/lib/savedir.c Tue Oct 12 16:18:34 1993 --- new/lib/savedir.c Mon Oct 25 20:57:42 1993 *************** *** 92,97 **** --- 92,104 ---- 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 -cbr orig/lib/stripslash.c new/lib/stripslash.c *** orig/lib/stripslash.c Tue Oct 12 16:18:40 1993 --- new/lib/stripslash.c Mon Oct 25 20:57:44 1993 *************** *** 31,36 **** --- 31,37 ---- #else #include #endif + #include /* Remove trailing slashes from PATH. This is useful when using filename completion from a shell that *************** *** 45,50 **** --- 46,75 ---- 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 -cbr orig/lib/system.h new/lib/system.h *** orig/lib/system.h Wed Oct 06 22:59:24 1993 --- new/lib/system.h Mon Oct 25 20:57:46 1993 *************** *** 130,136 **** --- 130,140 ---- #undef HAVE_MAJOR #ifdef _POSIX_VERSION + #ifdef OS2 + #include + #else #include + #endif #else /* not _POSIX_VERSION */ struct utimbuf { *************** *** 272,275 **** --- 276,304 ---- char *alloca (); #endif #endif + #endif + + extern const char *version_string; + #define print_version(x) \ + fprintf(stderr, "\nGNU %s, fileutils version %3.3s\n\n", \ + x, version_string + 14) + + #ifdef OS2 + #include + #include + #ifndef isdigit + #include + #endif + #define geteuid() 1 + #define getegid() 1 + #define chdir(d) _chdir2(d) + #define getcwd(b, s) _getcwd2(b, s) + #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 chown(path, uid, gid) 0 + #define sync() 0 + #define lstat stat + #define main(c, v) os2main(c, v) + extern char *fix_colon(char *); #endif diff -cbr orig/lib/userspec.c new/lib/userspec.c *** orig/lib/userspec.c Tue Oct 12 16:18:44 1993 --- new/lib/userspec.c Mon Oct 25 20:57:46 1993 *************** *** 30,37 **** --- 30,39 ---- #include #include + #ifndef OS2 #include #include + #endif #if defined(STDC_HEADERS) || defined(HAVE_STRING_H) #include *************** *** 118,123 **** --- 120,128 ---- *groupname = strdup (cp); if (*groupname == NULL) return tired; + #ifdef OS2 + *gid = 0; + #else grp = getgrnam (cp); if (grp == NULL) { *************** *** 128,133 **** --- 133,139 ---- else *gid = grp->gr_gid; endgrent (); /* Save a file descriptor. */ + #endif } } *************** *** 141,146 **** --- 147,155 ---- if (*username == NULL) return tired; + #ifdef OS2 + *uid = *gid = 0; + #else pwd = getpwnam (name); if (pwd == NULL) { *************** *** 174,179 **** --- 183,189 ---- } } endpwent (); + #endif return NULL; } diff -cbr orig/lib/xgetcwd.c new/lib/xgetcwd.c *** orig/lib/xgetcwd.c Tue Oct 12 16:18:48 1993 --- new/lib/xgetcwd.c Mon Oct 25 20:58:08 1993 *************** *** 35,46 **** --- 35,49 ---- #endif #include #include "pathmax.h" + #include "system.h" #if !defined(_POSIX_VERSION) && !defined(HAVE_GETCWD) char *getwd (); #define getcwd(buf, max) getwd (buf) #else + #ifndef getcwd char *getcwd (); + #endif #endif /* Amount to increase buffer size by in each try. */ diff -cbr orig/src/chmod.c new/src/chmod.c *** orig/src/chmod.c Tue Oct 19 00:35:04 1993 --- new/src/chmod.c Mon Oct 25 22:05:26 1993 *************** *** 108,114 **** { thisind = optind ? optind : 1; ! c = getopt_long (argc, argv, "RcfvrwxXstugoa,+-=", long_options, (int *) 0); if (c == EOF) break; --- 108,114 ---- { thisind = optind ? optind : 1; ! c = getopt_long (argc, argv, "RcfvrwxXstugoah,+-=", long_options, (int *) 0); if (c == EOF) break; *************** *** 127,132 **** --- 127,135 ---- case 'g': case 'o': case 'a': + #ifdef OS2 + case 'h': + #endif case ',': case '+': case '-': *************** *** 166,172 **** modeind = optind++; if (optind >= argc) ! usage (1); changes = mode_compile (argv[modeind], MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS); --- 169,175 ---- modeind = optind++; if (optind >= argc) ! usage (0); changes = mode_compile (argv[modeind], MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS); *************** *** 195,200 **** --- 198,206 ---- struct stat file_stats; unsigned short newmode; int errors = 0; + #ifdef OS2 + unsigned extmode = getfmode(file); + #endif if (lstat (file, &file_stats)) { *************** *** 215,222 **** --- 221,250 ---- } #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) *************** *** 231,236 **** --- 259,268 ---- 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; *************** *** 316,321 **** --- 348,354 ---- usage (status) int status; { + print_version("chmod"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); diff -cbr orig/src/cp-aux.c new/src/cp-aux.c *** orig/src/cp-aux.c Tue Oct 19 00:35:06 1993 --- new/src/cp-aux.c Mon Oct 25 21:59:44 1993 *************** *** 39,44 **** --- 39,45 ---- int status; char *reason; { + print_version("cp"); if (reason != NULL) fprintf (status == 0 ? stdout : stderr, "%s: %s\n", program_name, reason); diff -cbr orig/src/cp.c new/src/cp.c *** orig/src/cp.c Tue Oct 19 00:35:08 1993 --- new/src/cp.c Mon Oct 25 22:21:16 1993 *************** *** 42,47 **** --- 42,56 ---- uid_t geteuid (); #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, and re_protect to keep a list of leading directories whose protections need to be fixed after copying. */ *************** *** 182,188 **** --- 191,201 ---- 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) *************** *** 288,294 **** --- 301,311 ---- 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. */ *************** *** 321,331 **** int ret = 0; if (optind >= argc) ! usage (2, "missing file arguments"); if (optind >= argc - 1) usage (2, "missing file argument"); dest = argv[argc - 1]; if (lstat (dest, &sb)) { --- 338,351 ---- int ret = 0; if (optind >= argc) ! usage (0, NULL); if (optind >= argc - 1) usage (2, "missing file argument"); dest = argv[argc - 1]; + #ifdef OS2 + dest = fix_colon(dest); + #endif if (lstat (dest, &sb)) { *************** *** 368,376 **** if (flag_path) { /* Append all of `arg' to `dest'. */ ! dst_path = xmalloc (strlen (dest) + strlen (arg) + 2); ! stpcpy (stpcpy (stpcpy (dst_path, dest), "/"), arg); /* For --parents, we have to make sure that the directory dirname (dst_path) exists. We may have to create a few --- 388,404 ---- if (flag_path) { + ap = arg; + #ifdef OS2 + if ( ap[1] == ':' && isalpha(ap[0]) ) + ap += 2; + #endif + if ( *ap == '/' ) + ap++; + /* Append all of `arg' to `dest'. */ ! dst_path = xmalloc (strlen (dest) + strlen (ap) + 2); ! stpcpy (stpcpy (stpcpy (dst_path, dest), "/"), ap); /* For --parents, we have to make sure that the directory dirname (dst_path) exists. We may have to create a few *************** *** 392,397 **** --- 420,428 ---- else { dst_path = xmalloc (strlen (dest) + strlen (ap) + 2); + if (dest[strlen(dest) - 1] == '/') + stpcpy (stpcpy (dst_path, dest), ap); + else stpcpy (stpcpy (stpcpy (dst_path, dest), "/"), ap); } } *************** *** 408,415 **** --- 439,448 ---- if (flag_path) { + #ifndef OS2 ret |= re_protect (dst_path, strlen (dest) + 1, attr_list); + #endif } } *************** *** 534,539 **** --- 567,578 ---- { /* The file exists already. */ + if (strcmp (dst_path, src_path) == 0) + { + 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) { if (flag_hard_link) *************** *** 599,604 **** --- 638,644 ---- { if (S_ISDIR (dst_sb.st_mode)) { + #ifndef OS2 /* Temporarily change mode to allow overwriting. */ if (eaccess_stat (&dst_sb, W_OK | X_OK) != 0) { *************** *** 610,615 **** --- 650,656 ---- else fix_mode = 1; } + #endif } else { *************** *** 631,636 **** --- 672,678 ---- 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? */ *************** *** 643,648 **** --- 685,691 ---- } return 0; } + #endif if (S_ISDIR (src_type)) { *************** *** 746,751 **** --- 789,795 ---- } else #endif + #ifndef OS2 if (S_ISBLK (src_type) || S_ISCHR (src_type) #ifdef S_ISSOCK || S_ISSOCK (src_type) *************** *** 759,764 **** --- 803,809 ---- } } else + #endif #ifdef S_ISLNK if (S_ISLNK (src_type)) { *************** *** 788,793 **** --- 833,842 ---- 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. */ *************** *** 799,805 **** --- 848,858 ---- 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; *************** *** 816,824 **** --- 869,886 ---- } 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; *************** *** 1138,1144 **** int last_write_made_hole = 0; int make_holes = 0; ! source_desc = open (src_path, O_RDONLY); if (source_desc < 0) { error (0, errno, "%s", src_path); --- 1200,1206 ---- int last_write_made_hole = 0; int make_holes = 0; ! source_desc = open (src_path, O_RDONLY | O_BINARY); if (source_desc < 0) { error (0, errno, "%s", src_path); *************** *** 1148,1154 **** /* 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); if (dest_desc < 0) { error (0, errno, "cannot create regular file `%s'", dst_path); --- 1210,1216 ---- /* 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 | O_BINARY, 0600); if (dest_desc < 0) { error (0, errno, "cannot create regular file `%s'", dst_path); diff -cbr orig/src/dd.c new/src/dd.c *** orig/src/dd.c Tue Oct 19 00:35:08 1993 --- new/src/dd.c Mon Nov 01 12:12:26 1993 *************** *** 65,71 **** --- 65,80 ---- #endif #include + + #ifdef __EMX__ + #define islower(c) IsLower(c) + #define isupper(c) IsUpper(c) + #define tolower(c) ToLower(c) + #define toupper(c) ToUpper(c) + #define isdigit(c) ('0' <= (c) && (c) <= '9') + #else #include + #endif #if !defined (isascii) || defined (STDC_HEADERS) #undef isascii *************** *** 83,90 **** --- 92,106 ---- #include "system.h" #include "version.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 (); \ *************** *** 187,192 **** --- 203,214 ---- 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; *************** *** 365,383 **** if (input_file != NULL) { ! input_fd = open (input_file, O_RDONLY); if (input_fd < 0) error (1, errno, "%s", input_file); } else input_file = "standard input"; if (input_fd == output_fd) error (1, 0, "standard %s is closed", input_fd == 0 ? "input" : "output"); if (output_file != NULL) { ! int omode = O_RDWR | O_CREAT; if (seek_record == 0 && !(conversions_mask & C_NOTRUNC)) omode |= O_TRUNC; --- 387,409 ---- if (input_file != NULL) { ! 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); + } if (input_fd == output_fd) error (1, 0, "standard %s is closed", input_fd == 0 ? "input" : "output"); if (output_file != NULL) { ! int omode = O_RDWR | O_CREAT | O_BINARY; if (seek_record == 0 && !(conversions_mask & C_NOTRUNC)) omode |= O_TRUNC; *************** *** 395,400 **** --- 421,431 ---- 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) *************** *** 603,610 **** --- 634,646 ---- } } else + { r_full++; + if (echo_progress) + fprintf (stderr, "\r%d ", r_full); + } + if (ibuf == obuf) /* If not C_TWOBUFS. */ { int nwritten = write (output_fd, obuf, nread); *************** *** 843,848 **** --- 879,888 ---- 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 *************** *** 1043,1049 **** static void print_stats () { ! 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) fprintf (stderr, "%u truncated record%s\n", r_truncate, --- 1083,1089 ---- static void print_stats () { ! fprintf (stderr, "\r%u+%u records in\n", r_full, r_partial); fprintf (stderr, "%u+%u records out\n", w_full, w_partial); if (r_truncate > 0) fprintf (stderr, "%u truncated record%s\n", r_truncate, *************** *** 1073,1078 **** --- 1113,1119 ---- usage (status) int status; { + print_version("dd"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); *************** *** 1091,1098 **** --- 1132,1143 ---- of=FILE write to FILE instead of stdout, don't truncate file\n\ seek=BLOCKS skip BLOCKS obs-sized blocks at start of output\n\ skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input\n\ + echo=on display progress by counting blocks on stdout\n\ + logdisk=on on floppy drives, use logical drive parameters\n\ --help display this help and exit\n\ --version output version information and exit\n\ + \n\ + FILE can also be a floppy drive name, such as A: or B:\n\ \n\ BYTES may be suffixed: by xM for multiplication by M, by c for x1,\n\ by w for x2, by b for x512, by k for x1024. Each KEYWORD may be:\n\ diff -cbr orig/src/df.c new/src/df.c *** orig/src/df.c Tue Oct 19 00:35:10 1993 --- new/src/df.c Mon Oct 25 22:07:54 1993 *************** *** 156,162 **** posix_format = 0; exit_status = 0; ! while ((i = getopt_long (argc, argv, "aikPt:vx:", long_options, (int *) 0)) != EOF) { switch (i) --- 156,162 ---- posix_format = 0; exit_status = 0; ! while ((i = getopt_long (argc, argv, "aikPt:vx:?", long_options, (int *) 0)) != EOF) { switch (i) *************** *** 164,170 **** --- 164,174 ---- 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; *************** *** 184,190 **** add_excluded_fs_type (optarg); break; default: ! usage (1); } } --- 188,194 ---- add_excluded_fs_type (optarg); break; default: ! usage (0); } } *************** *** 199,210 **** --- 203,228 ---- if (optind != argc) { + #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; *************** *** 241,247 **** --- 259,269 ---- print_header () { if (inode_format) + #ifdef OS2 + printf ("Filesystem Type "); + #else printf ("Filesystem Inodes IUsed IFree %%IUsed"); + #endif else printf ("Filesystem %s Used Available Capacity", kilobyte_blocks ? "1024-blocks" : " 512-blocks"); *************** *** 268,277 **** --- 290,307 ---- char *path; 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 } /* Identify the directory, if any, that device *************** *** 284,290 **** --- 314,324 ---- struct mount_entry *me; for (me = mount_list; me; me = me->me_next) + #ifdef OS2 + if (!strcmp (disk, me->me_mountdir)) + #else if (!strcmp (disk, me->me_devname)) + #endif { show_dev (me->me_devname, me->me_mountdir, me->me_type); return; *************** *** 293,298 **** --- 327,333 ---- 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. */ *************** *** 328,333 **** --- 363,369 ---- error (0, 0, "cannot find mount point for %s", point); exit_status = 1; } + #endif /* Display a space listing for the disk device with absolute path DISK. If MOUNT_POINT is non-NULL, it is the path of the root of the *************** *** 399,406 **** --- 435,446 ---- printf ("\n "); 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 printf (" %7ld %7ld %7ld %5ld%% ", fsu.fsu_blocks, blocks_used, fsu.fsu_bavail, blocks_percent_used); *************** *** 450,456 **** if (fs_select_list == NULL || fstype == NULL) return 1; for (fsp = fs_select_list; fsp; fsp = fsp->fs_next) ! if (!strcmp (fstype, fsp->fs_name)) return 1; return 0; } --- 490,496 ---- if (fs_select_list == NULL || fstype == NULL) return 1; for (fsp = fs_select_list; fsp; fsp = fsp->fs_next) ! if (strstr (fstype, fsp->fs_name)) return 1; return 0; } *************** *** 477,482 **** --- 517,523 ---- usage (status) int status; { + print_version("df"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); diff -cbr orig/src/du.c new/src/du.c *** orig/src/du.c Tue Oct 19 00:35:12 1993 --- new/src/du.c Mon Oct 25 22:07:30 1993 *************** *** 195,200 **** --- 195,201 ---- int status; char *reason; { + print_version("du"); if (reason != NULL) fprintf (status == 0 ? stdout : stderr, "%s: %s\n", program_name, reason); *************** *** 234,240 **** xstat = lstat; output_size = getenv ("POSIXLY_CORRECT") ? size_blocks : size_kilobytes; ! while ((c = getopt_long (argc, argv, "abcklsxDLS", long_options, (int *) 0)) != EOF) { switch (c) --- 235,241 ---- xstat = lstat; output_size = getenv ("POSIXLY_CORRECT") ? size_blocks : size_kilobytes; ! while ((c = getopt_long (argc, argv, "abcklsxDLS?", long_options, (int *) 0)) != EOF) { switch (c) *************** *** 283,289 **** break; default: ! usage (2, (char *) 0); } } --- 284,290 ---- break; default: ! usage (0, (char *) 0); } } *************** *** 351,356 **** --- 352,360 ---- 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; *************** *** 411,420 **** --- 415,426 ---- 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; *************** *** 447,453 **** if (errno) { error (0, errno, "%s", path->text); ! if (chdir ("..") < 0) /* Try to return to previous dir. */ error (1, errno, "cannot change to `..' from directory %s", path->text); exit_status = 1; --- 453,460 ---- if (errno) { error (0, errno, "%s", path->text); ! if (chdir ("..") < 0 && errno != ENOENT) ! /* Try to return to previous dir. */ error (1, errno, "cannot change to `..' from directory %s", path->text); exit_status = 1; *************** *** 473,479 **** namep += strlen (namep) + 1; } free (name_space); ! if (chdir ("..") < 0) error (1, errno, "cannot change to `..' from directory %s", path->text); str_trunc (path, pathlen - 1); /* Remove the "/" we added. */ --- 480,486 ---- namep += strlen (namep) + 1; } free (name_space); ! if (chdir ("..") < 0 && errno != ENOENT) error (1, errno, "cannot change to `..' from directory %s", path->text); str_trunc (path, pathlen - 1); /* Remove the "/" we added. */ diff -cbr orig/src/install.c new/src/install.c *** orig/src/install.c Tue Oct 19 00:35:12 1993 --- new/src/install.c Mon Oct 25 22:07:14 1993 *************** *** 67,74 **** --- 67,78 ---- #include #include #include + #ifdef OS2 + #include + #else #include #include + #endif #include "system.h" #include "version.h" #include "modechange.h" *************** *** 80,85 **** --- 84,90 ---- #define ISDIGIT(c) (isascii (c) && isdigit (c)) + #ifndef OS2 #ifdef _POSIX_VERSION #include #else *************** *** 89,94 **** --- 94,100 ---- gid_t getgid (); int wait (); #endif + #endif #ifdef _POSIX_SOURCE #define endgrent() *************** *** 221,227 **** if ((dir_arg && strip_files) || (optind == argc) || (optind == argc - 1 && !dir_arg)) ! usage (1); if (symbolic_mode) { --- 227,233 ---- if ((dir_arg && strip_files) || (optind == argc) || (optind == argc - 1 && !dir_arg)) ! usage (0); if (symbolic_mode) { *************** *** 358,364 **** target_created = 0; } ! fromfd = open (from, O_RDONLY, 0); if (fromfd == -1) { error (0, errno, "%s", from); --- 364,370 ---- target_created = 0; } ! fromfd = open (from, O_RDONLY | O_BINARY, 0); if (fromfd == -1) { error (0, errno, "%s", from); *************** *** 366,372 **** } /* Make sure to open the file in a mode that allows writing. */ ! tofd = open (to, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (tofd == -1) { error (0, errno, "%s", to); --- 372,378 ---- } /* Make sure to open the file in a mode that allows writing. */ ! tofd = open (to, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600); if (tofd == -1) { error (0, errno, "%s", to); *************** *** 399,404 **** --- 405,415 ---- } if (ret == 0) *to_created = target_created; + + #ifdef OS2 + CopyEAs(from, to); + #endif + return ret; copy_error: *************** *** 460,465 **** --- 471,479 ---- strip (path) char *path; { + #ifdef OS2 + spawnlp (P_WAIT, "strip", "strip", path, (char *) NULL); + #else int pid, status; pid = fork (); *************** *** 478,483 **** --- 492,498 ---- /* Do nothing. */ ; break; } + #endif } /* Initialize the user and group ownership of the files to install. */ *************** *** 485,490 **** --- 500,506 ---- static void get_ids () { + #ifndef OS2 struct passwd *pw; struct group *gr; *************** *** 519,524 **** --- 535,541 ---- } else group_id = getgid (); + #endif } /* Return nonzero if STR is an ASCII representation of a nonzero *************** *** 540,545 **** --- 557,563 ---- usage (status) int status; { + print_version("install"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); diff -cbr orig/src/ls.c new/src/ls.c *** orig/src/ls.c Tue Oct 19 00:35:14 1993 --- new/src/ls.c Mon Oct 25 22:09:14 1993 *************** *** 52,59 **** --- 52,61 ---- #include #endif #include + #ifndef OS2 #include #include + #endif #include #include "system.h" #include *************** *** 376,381 **** --- 378,389 ---- /* If non-zero, 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'}, *************** *** 403,408 **** --- 411,419 ---- {"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}, {0, 0, 0, 0} *************** *** 480,487 **** --- 491,526 ---- 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) { *************** *** 603,609 **** p = getenv ("TABSIZE"); tabsize = p ? atoi (p) : 8; ! while ((c = getopt_long (argc, argv, "abcdfgiklmnpqrstuw:xABCFGI:LNQRST:UX1", long_options, (int *) 0)) != EOF) { switch (c) --- 642,648 ---- p = getenv ("TABSIZE"); tabsize = p ? atoi (p) : 8; ! while ((c = getopt_long (argc, argv, "abcdfgiklmnpqrstuw:xABCFGI:LNQRST:UX1?h", long_options, (int *) 0)) != EOF) { switch (c) *************** *** 796,802 **** break; default: ! usage (1); } } --- 835,841 ---- break; default: ! usage (0); } } *************** *** 919,931 **** if (fnmatch (ignore->pattern, next->d_name, FNM_PERIOD) == 0) return 0; 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; ! return 0; } --- 958,979 ---- if (fnmatch (ignore->pattern, next->d_name, FNM_PERIOD) == 0) return 0; + #ifdef OS2 + if (really_all_files + || (next->d_name[0] != '.' && !(next->d_mode & (A_SYSTEM | A_HIDDEN)) ) + || (all_files + && next->d_name[1] != '\0' + && (next->d_name[1] != '.' || next->d_name[2] != '\0') + && !(next->d_mode & 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; } *************** *** 972,982 **** files[files_index].linkname = 0; files[files_index].linkmode = 0; - if (explicit_arg || format_needs_stat) - { /* `path' is the absolute pathname of this file. */ if (name[0] == '/' || dirname[0] == 0) path = name; else { --- 1020,1032 ---- files[files_index].linkname = 0; files[files_index].linkmode = 0; /* `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 = name; else { *************** *** 984,989 **** --- 1034,1041 ---- attach (path, dirname, name); } + if (explicit_arg || format_needs_stat) + { if (trace_links) { val = stat (path, &files[files_index].stat); *************** *** 996,1001 **** --- 1048,1055 ---- 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; *************** *** 1163,1169 **** --- 1217,1227 ---- 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); } *************** *** 1431,1437 **** break; } ! strcpy (timebuf, ctime (&when)); if (full_time) timebuf[24] = '\0'; --- 1489,1495 ---- break; } ! strcpy (timebuf, when > 0 ? ctime (&when) : " invalid date"); if (full_time) timebuf[24] = '\0'; *************** *** 1461,1471 **** --- 1519,1538 ---- /* The space between the mode and the number of links is the POSIX "optional alternate access method flag". */ + #ifdef OS2 + if (!unix_mode) + printf ("%-4.4s%-3.3s ", modebuf, modestring(f->stat.st_attr)); + else + #endif printf ("%s %3u ", modebuf, f->stat.st_nlink); + if (numeric_users) printf ("%-8u ", (unsigned int) f->stat.st_uid); else + #ifdef OS2 + if (unix_mode) + #endif printf ("%-8.8s ", getuser (f->stat.st_uid)); if (!inhibit_group) *************** *** 1473,1482 **** --- 1540,1556 ---- if (numeric_users) printf ("%-8u ", (unsigned int) f->stat.st_gid); else + #ifdef OS2 + if (unix_mode) + #endif printf ("%-8.8s ", getgroup (f->stat.st_gid)); } + #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 printf ("%3u, %3u ", (unsigned) major (f->stat.st_rdev), (unsigned) minor (f->stat.st_rdev)); else *************** *** 1548,1554 **** --- 1622,1632 ---- break; default: + #ifdef OS2 + if (c > 040 && c < 0377 && c != 0177) + #else if (c > 040 && c < 0177) + #endif putchar (c); else printf ("\\%03o", (unsigned int) c); *************** *** 1556,1562 **** --- 1634,1644 ---- } else { + #ifdef OS2 + if (c >= 040 && c < 0377 && c != 0177) + #else if (c >= 040 && c < 0177) + #endif putchar (c); else if (!qmark_funny_chars) putchar (c); *************** *** 1868,1874 **** --- 1950,1960 ---- 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) *************** *** 1880,1885 **** --- 1966,1978 ---- usage (status) 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 -cbr orig/src/mkdir.c new/src/mkdir.c *** orig/src/mkdir.c Tue Oct 19 00:35:16 1993 --- new/src/mkdir.c Mon Nov 01 12:47:02 1993 *************** *** 113,119 **** usage (0); if (optind == argc) ! usage (1); newmode = 0777 & ~umask (0); parent_mode = newmode | 0300; /* u+wx */ --- 113,119 ---- usage (0); if (optind == argc) ! usage (0); newmode = 0777 & ~umask (0); parent_mode = newmode | 0300; /* u+wx */ *************** *** 129,134 **** --- 129,137 ---- for (; optind < argc; ++optind) { + #ifdef OS2 + UnixFileName (argv[optind]); + #endif if (path_mode) errors |= make_path (argv[optind], newmode, parent_mode, -1, -1, NULL); else if (mkdir (argv[optind], newmode)) *************** *** 145,150 **** --- 148,154 ---- usage (status) int status; { + print_version("mkdir"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); diff -cbr orig/src/mv.c new/src/mv.c *** orig/src/mv.c Tue Oct 19 00:35:18 1993 --- new/src/mv.c Mon Oct 25 22:21:58 1993 *************** *** 128,134 **** int c; int errors; int make_backups = 0; ! char *version; version = getenv ("SIMPLE_BACKUP_SUFFIX"); if (version) --- 128,134 ---- int c; int errors; int make_backups = 0; ! char *version, *target; version = getenv ("SIMPLE_BACKUP_SUFFIX"); if (version) *************** *** 184,190 **** usage (0); if (argc < optind + 2) ! usage (1); if (make_backups) backup_type = get_version (version); --- 184,190 ---- usage (0); if (argc < optind + 2) ! usage (0); if (make_backups) backup_type = get_version (version); *************** *** 194,202 **** if (argc > optind + 2 && !isdir (argv[argc - 1])) error (1, 0, "when moving multiple files, last argument must be a directory"); /* Move each arg but the last onto the last. */ for (; optind < argc - 1; ++optind) ! errors |= movefile (argv[optind], argv[argc - 1]); exit (errors); } --- 194,207 ---- if (argc > optind + 2 && !isdir (argv[argc - 1])) error (1, 0, "when moving multiple files, last argument must be a directory"); + target = argv[argc - 1]; + #ifdef OS2 + target = fix_colon(target); + #endif + /* Move each arg but the last onto the last. */ for (; optind < argc - 1; ++optind) ! errors |= movefile (argv[optind], target); exit (errors); } *************** *** 231,236 **** --- 236,244 ---- base = basename (source); new_dest = (char *) alloca (strlen (dest) + 1 + strlen (base) + 1); + if (dest[strlen(dest) - 1] == '/') + stpcpy (stpcpy (new_dest, dest), base); + else stpcpy (stpcpy (stpcpy (new_dest, dest), "/"), base); return do_move (source, new_dest); } *************** *** 259,270 **** --- 267,286 ---- if (lstat (dest, &dest_stats) == 0) { + #ifdef OS2 + if (_fncmp (source, dest) == 0) + { + error (0, 0, "`%s': can't move file to itself", source); + return 1; + } + #else if (source_stats.st_dev == dest_stats.st_dev && source_stats.st_ino == dest_stats.st_ino) { error (0, 0, "`%s' and `%s' are the same file", source, dest); return 1; } + #endif if (S_ISDIR (dest_stats.st_mode)) { *************** *** 379,391 **** return 1; } ! ifd = open (source, O_RDONLY, 0); if (ifd < 0) { error (0, errno, "%s", source); return 1; } ! ofd = open (dest, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (ofd < 0) { error (0, errno, "%s", dest); --- 395,407 ---- return 1; } ! 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 | O_BINARY, 0600); if (ofd < 0) { error (0, errno, "%s", dest); *************** *** 437,442 **** --- 453,462 ---- /* 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; *************** *** 459,465 **** --- 479,490 ---- 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; *************** *** 472,477 **** --- 497,503 ---- usage (status) int status; { + print_version("mv"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); diff -cbr orig/src/rm.c new/src/rm.c *** orig/src/rm.c Tue Oct 19 00:35:20 1993 --- new/src/rm.c Mon Oct 25 22:09:26 1993 *************** *** 163,169 **** if (ignore_missing_files) exit (0); else ! usage (1); } stdin_tty = isatty (0); --- 163,169 ---- if (ignore_missing_files) exit (0); else ! usage (0); } stdin_tty = isatty (0); *************** *** 207,213 **** --- 207,217 ---- if (lstat (pathname, &path_stats)) { + #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; *************** *** 363,379 **** --- 367,397 ---- 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); *************** *** 410,415 **** --- 428,434 ---- name_space = new_name_space; } namep = stpcpy (namep, dp->d_name) + 1; + count++; if (inodep == inode_space + n_inodes_allocated) { *************** *** 475,481 **** } } /* Keep trying while there are still files to remove. */ ! while (namep > name_space && err == 0); free (name_space); free (inode_space); --- 494,500 ---- } } /* Keep trying while there are still files to remove. */ ! while (namep > name_space && err == 0 && count != lastcount); free (name_space); free (inode_space); *************** *** 530,535 **** --- 549,555 ---- usage (status) int status; { + print_version("rm"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); diff -cbr orig/src/rmdir.c new/src/rmdir.c *** orig/src/rmdir.c Tue Oct 19 00:35:22 1993 --- new/src/rmdir.c Mon Oct 25 22:06:38 1993 *************** *** 101,107 **** usage (0); if (optind == argc) ! usage (1); for (; optind < argc; ++optind) { --- 101,107 ---- usage (0); if (optind == argc) ! usage (0); for (; optind < argc; ++optind) { *************** *** 147,152 **** --- 147,153 ---- usage (status) int status; { + print_version("rmdir"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); diff -cbr orig/src/touch.c new/src/touch.c *** orig/src/touch.c Tue Oct 19 00:35:22 1993 --- new/src/touch.c Mon Oct 25 22:06:26 1993 *************** *** 249,256 **** if (optind == argc) { error (0, 0, "file arguments missing"); ! usage (1); } for (; optind < argc; ++optind) --- 249,258 ---- if (optind == argc) { + #ifndef OS2 error (0, 0, "file arguments missing"); ! #endif ! usage (0); } for (; optind < argc; ++optind) *************** *** 379,384 **** --- 381,387 ---- usage (status) int status; { + print_version("touch"); if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); diff -cbr orig/src/version.c new/src/version.c *** orig/src/version.c Tue Oct 19 05:46:56 1993 --- new/src/version.c Mon Oct 25 21:57:48 1993 *************** *** 11,13 **** --- 11,29 ---- #include "version.h" const char *version_string = "GNU fileutils 3.9"; + + #ifdef __EMX__ + + #include + + int main(int argc, char **argv) + { + _response(&argc, &argv); + _wildcard(&argc, &argv); + _nls_init(); + set_program_name(argv[0]); + setvbuf(stdout, NULL, _IOLBF, BUFSIZ); + return os2main(argc, argv); + } + + #endif