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, 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.



Home | Main Index | Thread Index | Old Index