tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Adding -l option to cp
On Sat, Jan 22, 2011 at 05:44:19PM -0500, D'Arcy J.M. Cain wrote:
> Index: utils.c
> ===================================================================
> RCS file: /cvsroot/src/bin/cp/utils.c,v
> retrieving revision 1.38
> diff -u -r1.38 utils.c
> --- utils.c 4 Jan 2011 10:35:10 -0000 1.38
> +++ utils.c 22 Jan 2011 22:38:22 -0000
> @@ -145,11 +145,23 @@
>
> rval = 0;
>
> + /* if hard linking then simply close the open fds, link and return */
> + if (lflag) {
> + (void)close(from_fd);
> + (void)close(to_fd);
> + (void)unlink(to.p_path);
> + if (link(entp->fts_path, to.p_path)) {
> + warn("%s", to.p_path);
> + return (1);
> + }
> + return (0);
> + }
> + /* NOTREACHED */
> +
(a) The lint comment is rather obviously misplaced.
(b) Why doesn't this fall-through if it can't create the hard-link?
In the current form it should be a form for ln and not for cp...
> @@ -192,6 +204,7 @@
> remainder -= chunk;
> } while (remainder > 0);
>
> + /* Some systems don't unmap on close(2). */
> if (munmap(p, fsize) < 0) {
> warn("%s", entp->fts_path);
> rval = 1;
This comment is misleading at the very least. mmap is not disestablished
by close(2). Doing it would break quite a few programs, including
dynamic linkage...
Joerg
Home |
Main Index |
Thread Index |
Old Index