tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Adding -l option to cp
On Sun, 23 Jan 2011 11:29:05 +0200
Alan Barrett <apb%cequrux.com@localhost> wrote:
> On Sat, 22 Jan 2011, D'Arcy J.M. Cain wrote:
> > + /* 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 */
>
> It should be possible to attempt linking earlier, before from_fd and
> to_fd are opened. If linking fails, it should fall through to
> copying.
Yes, I did try to think of better ways but it always seemed more
convoluted. As for falling back to copying, I'm not so sure.
Certainly I need it to fail in my application. I am also trying to
keep the actual behaviour as the other systems.
--
D'Arcy J.M. Cain <darcy%NetBSD.org@localhost>
http://www.NetBSD.org/
Home |
Main Index |
Thread Index |
Old Index