Article View: gnu.utils.bug
Article #499a slight enhancement to the GNU `mv'
From: Robert S. Maier
Date: Sun, 15 Oct 1989 01:39
Date: Sun, 15 Oct 1989 01:39
48 lines
2037 bytes
2037 bytes
The following is a slight enhancement to the GNU `mv', written by Mike
Parker.
Like the BSD mv (the only one I'm familiar with) the GNU mv asks the
user ``Override mode xxx for filename?'' if access(2) reports no write
access to the target file. But write access can be denied for reasons
other than bad permission flags. In particular it can be denied if
the target is on a read-only filesystem, or if the target is a busy
executable.
The following diff uses perror(3) to report such problems. I have
already found it useful...
--
Robert S. Maier | Internet: rsm@math.arizona.edu [128.196.128.99]
Dept. of Math. | UUCP: ..{allegra,cmcl2,hao!noao}!arizona!amethyst!rsm
Univ. of Arizona | Bitnet: maier@arizrvax
Tucson, AZ 85721 | FAX: +1 602 621 8322
U.S.A. | Voice: +1 602 621 6893 / +1 602 621 2617
----------------------------------------------------------------------
224,226c224,226
< if ((access (to, W_OK) < 0 ||
< (stb.st_mode & ((S_IWRITE>>6)*0111)) == 0)
< && !force )
---
> if ( (access (to, W_OK) < 0 ||
> (stb.st_mode & ((S_IWRITE>>6)*0111)) == 0)
> && !force )
228,230c228,240
< printf ("Override mode %04o for `%s'? ", stb.st_mode & 0777 ,to);
< if (! yes ())
< return;
---
> if (errno == EACCES || (stb.st_mode & ((S_IWRITE>>6)*0111)) == 0)
> {
> printf ("Override mode %04o for `%s'? ", stb.st_mode & 0777 ,to);
> if (! yes ())
> return;
> }
> else /* RO filesystem, text busy etc. */
> {
> fprintf (stderr, "%s: no write access to `%s': ",
> pgm, to);
> perror (0);
> return;
> }
Technical Details
Message-ID:
<RSM.89Oct14183935@onyx.math.arizona.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!noao!amethyst!rsmShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!noao!amethyst!rsm From: rsm@math.arizona.edu (Robert S. Maier) Newsgroups: gnu.utils.bug Subject: a slight enhancement to the GNU `mv' Message-ID: <RSM.89Oct14183935@onyx.math.arizona.edu> Date: 15 Oct 89 01:39:35 GMT Organization: University of Arizona Mathematics Department Lines: 48