diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-11-29 19:09:16 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-11-29 19:09:16 +0000 |
commit | 86fe737e5c77e063b373d5d01c693c1fd1062a27 (patch) | |
tree | c35eb41b3e4cf8ad39724e2185d22daa224186f2 | |
parent | 0e6f42e86bc904058928ea4bab27b17e25198a13 (diff) | |
download | paxutils-86fe737e5c77e063b373d5d01c693c1fd1062a27.tar.gz |
* lib/rtapelib.c (encode_oflag): Simplify code, since O_NONBLOCK
is always defined now.
* paxlib/rtape.c (encode_oflag): Likewise.
* lib/system.h (O_DIRCTORY, O_NOATIME, O_NONBLOCK): Define to 0
if not already defined.
* paxlib/error.c (rmdir_error): New function.
* paxlib/error.h (rmdir_error): New decl.
* rmt/rmt.c (decode_oflag): Use '#if O_NONBLOCK", not ifdef.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | build-aux/gnulib.modules | 15 | ||||
-rw-r--r-- | lib/rtapelib.c | 8 | ||||
-rw-r--r-- | lib/system.h | 13 | ||||
-rw-r--r-- | paxlib/error.c | 6 | ||||
-rw-r--r-- | paxlib/paxlib.h | 1 | ||||
-rw-r--r-- | paxlib/rtape.c | 17 | ||||
-rw-r--r-- | rmt/rmt.c | 48 |
8 files changed, 72 insertions, 47 deletions
@@ -1,3 +1,14 @@ +2005-11-29 Paul Eggert <eggert@cs.ucla.edu> + + * lib/rtapelib.c (encode_oflag): Simplify code, since O_NONBLOCK + is always defined now. + * paxlib/rtape.c (encode_oflag): Likewise. + * lib/system.h (O_DIRCTORY, O_NOATIME, O_NONBLOCK): Define to 0 + if not already defined. + * paxlib/error.c (rmdir_error): New function. + * paxlib/error.h (rmdir_error): New decl. + * rmt/rmt.c (decode_oflag): Use '#if O_NONBLOCK", not ifdef. + 2005-11-06 Paul Eggert <eggert@cs.ucla.edu> * lib/system.h (strtoimax, strtoumax): Declare if the system diff --git a/build-aux/gnulib.modules b/build-aux/gnulib.modules index 6b0b649..0b25909 100644 --- a/build-aux/gnulib.modules +++ b/build-aux/gnulib.modules @@ -2,16 +2,19 @@ # A module name per line. Empty lines and comments are ignored. argp -savedir -unlocked-io -fileblocks -error -gettext -inttostr dirname +error +fileblocks full-write getopt +gettext +hash +inttostr +quote +quotearg safe-read +savedir stdbool strtol +unlocked-io xalloc diff --git a/lib/rtapelib.c b/lib/rtapelib.c index d75b267..b352762 100644 --- a/lib/rtapelib.c +++ b/lib/rtapelib.c @@ -1,7 +1,7 @@ /* Functions for communicating with a remote tape drive. - Copyright 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2004 Free - Software Foundation, Inc. + Copyright 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2004, + 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -340,9 +340,7 @@ encode_oflag (char *buf, int oflag) #ifdef O_NOCTTY if (oflag & O_NOCTTY) strcat (buf, "|O_NOCTTY"); #endif -#ifdef O_NONBLOCK if (oflag & O_NONBLOCK) strcat (buf, "|O_NONBLOCK"); -#endif #ifdef O_RSYNC if (oflag & O_RSYNC) strcat (buf, "|O_RSYNC"); #endif @@ -358,7 +356,7 @@ encode_oflag (char *buf, int oflag) remote pipe number plus BIAS. REMOTE_SHELL may be overridden. On error, return -1. */ int -rmt_open__ (const char *file_name, int open_mode, int bias, +rmt_open__ (const char *file_name, int open_mode, int bias, const char *remote_shell) { int remote_pipe_number; /* pseudo, biased file descriptor */ diff --git a/lib/system.h b/lib/system.h index be2c2eb..a36e061 100644 --- a/lib/system.h +++ b/lib/system.h @@ -109,10 +109,19 @@ extern int errno; #ifndef O_TRUNC # define O_TRUNC 32 /* truncate file on open */ #endif - /* MS-DOG forever, with my love! */ -#ifndef O_BINARY + +#ifndef O_BINARY # define O_BINARY 0 #endif +#ifndef O_DIRECTORY +# define O_DIRECTORY 0 +#endif +#ifndef O_NOATIME +# define O_NOATIME 0 +#endif +#ifndef O_NONBLOCK +# define O_NONBLOCK 0 +#endif /* Declare file status routines and bits. */ diff --git a/paxlib/error.c b/paxlib/error.c index b2bf3d6..1fe2909 100644 --- a/paxlib/error.c +++ b/paxlib/error.c @@ -228,6 +228,12 @@ readlink_warn (char const *name) } void +rmdir_error (char const *name) +{ + call_arg_error ("rmdir", name); +} + +void savedir_error (char const *name) { call_arg_error ("savedir", name); diff --git a/paxlib/paxlib.h b/paxlib/paxlib.h index c9b3036..381c4c7 100644 --- a/paxlib/paxlib.h +++ b/paxlib/paxlib.h @@ -81,6 +81,7 @@ void read_fatal_details (char const *, off_t, size_t) __attribute__ ((noreturn)) void read_warn_details (char const *, off_t, size_t); void readlink_error (char const *); void readlink_warn (char const *); +void rmdir_error (char const *); void savedir_error (char const *); void savedir_warn (char const *); void seek_error (char const *); diff --git a/paxlib/rtape.c b/paxlib/rtape.c index 22307fe..90ac263 100644 --- a/paxlib/rtape.c +++ b/paxlib/rtape.c @@ -310,15 +310,15 @@ encode_oflag (char *buf, int oflag) case O_RDONLY: strcat (buf, "O_RDONLY"); break; - + case O_RDWR: strcat (buf, "O_RDWR"); break; - + case O_WRONLY: strcat (buf, "O_WRONLY"); break; - + default: abort (); } @@ -343,10 +343,8 @@ encode_oflag (char *buf, int oflag) if (oflag & O_NOCTTY) strcat (buf, "|O_NOCTTY"); #endif -#ifdef O_NONBLOCK if (oflag & O_NONBLOCK) strcat (buf, "|O_NONBLOCK"); -#endif #ifdef O_RSYNC if (oflag & O_RSYNC) strcat (buf, "|O_RSYNC"); @@ -508,7 +506,7 @@ rmt_open (const char *file_name, int open_mode, int bias, if (!rmt_command) rmt_command = DEFAULT_RMT_COMMAND; - + if (remote_user) execl (remote_shell, remote_shell_basename, remote_host, "-l", remote_user, rmt_command, (char *) 0); @@ -650,15 +648,15 @@ rmt_lseek (int handle, off_t offset, int whence) case SEEK_SET: whence = 0; break; - + case SEEK_CUR: whence = 1; break; - + case SEEK_END: whence = 2; break; - + default: abort (); } @@ -758,4 +756,3 @@ rmt_ioctl (int handle, int operation, char *argument) } } - @@ -197,7 +197,7 @@ decode_oflag (char const *oflag_string) #ifdef O_NOCTTY {"NOCTTY", O_NOCTTY}, #endif -#ifdef O_NONBLOCK +#if O_NONBLOCK {"NONBLOCK", O_NONBLOCK}, #endif {"RDONLY", O_RDONLY}, @@ -321,15 +321,15 @@ lseek_device (void) int negative; int whence; char *p; - + get_string (count_string); get_string (position_string); DEBUG2 ("rmtd: L %s %s\n", count_string, position_string); - + /* Parse count_string, taking care to check for overflow. We can't use standard functions, since off_t might be longer than long. */ - + for (p = count_string; *p == ' ' || *p == '\t'; p++) ; @@ -362,20 +362,20 @@ lseek_device (void) case 0: whence = SEEK_SET; break; - + case 1: whence = SEEK_CUR; break; - + case 2: whence = SEEK_END; break; - + default: report_error_message (N_("Seek direction out of range")); exit (EXIT_FAILURE); } - + count = lseek (tape, count, whence); if (count < 0) report_numbered_error (errno); @@ -389,9 +389,9 @@ lseek_device (void) do *--p = '0' + (int) (count % 10); while ((count /= 10) != 0); - + DEBUG1 ("rmtd: A %s\n", p); - + sprintf (reply_buffer, "A%s\n", p); full_write (STDOUT_FILENO, reply_buffer, strlen (reply_buffer)); } @@ -404,11 +404,11 @@ write_device (void) size_t size; size_t counter; size_t status = 0; - + get_string (count_string); size = get_long (count_string); DEBUG1 ("rmtd: W %s\n", count_string); - + prepare_input_buffer (STDIN_FILENO, size); for (counter = 0; counter < size; counter += status) { @@ -417,7 +417,7 @@ write_device (void) if (status == SAFE_READ_ERROR || status == 0) { DEBUG (_("rmtd: Premature eof\n")); - + report_error_message (N_("Premature end of file")); exit (EXIT_FAILURE); /* exit status used to be 2 */ } @@ -435,10 +435,10 @@ read_device (void) char count_string[STRING_SIZE]; size_t size; size_t status; - + get_string (count_string); DEBUG1 ("rmtd: R %s\n", count_string); - + size = get_long (count_string); prepare_input_buffer (-1, size); status = safe_read (tape, record_buffer, size); @@ -524,7 +524,7 @@ status_device (void) #ifdef MTIOCGET { struct mtget operation; - + if (ioctl (tape, MTIOCGET, (char *) &operation) < 0) report_numbered_error (errno); else @@ -534,7 +534,7 @@ status_device (void) } #endif } -} +} int main (int argc, char **argv) @@ -590,7 +590,7 @@ see the file named COPYING for details.")); while (1) { errno = 0; - + if (safe_read (STDIN_FILENO, &command, 1) != 1) return EXIT_SUCCESS; @@ -599,15 +599,15 @@ see the file named COPYING for details.")); case 'O': open_device (); break; - + case 'C': close_device (); break; - + case 'L': lseek_device (); break; - + case 'W': write_device (); break; @@ -615,15 +615,15 @@ see the file named COPYING for details.")); case 'R': read_device (); break; - + case 'I': mtioctop (); break; - + case 'S': status_device (); break; - + default: DEBUG1 (_("rmtd: Garbage command %c\n"), command); report_error_message (N_("Garbage command")); |