Patch to add link (SUSv2) utility

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch to add link (SUSv2) utility

Andrés Delfino
This patch lets ln(1) handle link(1), just like in FreeBSD. In fact, I
took all the lines I added from FreeBSD's ln. I don't know if one
needs to add the license notice for those lines.

http://www.opengroup.org/onlinepubs/000095399/utilities/link.html

PS: If you are fine with this, I'll send unlink(1) patch too.

Index: src/bin/ln/ln.c
===================================================================
RCS file: /cvs/src/bin/ln/ln.c,v
retrieving revision 1.14
diff -u -r1.14 ln.c
--- src/bin/ln/ln.c 25 Apr 2006 04:38:26 -0000 1.14
+++ src/bin/ln/ln.c 5 Sep 2006 13:04:19 -0000
@@ -70,7 +70,28 @@
 {
  struct stat sb;
  int ch, exitval;
- char *sourcedir;
+ char *p, *sourcedir;
+
+ /*
+ * Test for the special case where the utility is called as
+ * "link", for which the functionality provided is greatly
+ * simplified.
+ */
+
+ if ((p = strrchr (argv[0], '/')) == NULL)
+ p = argv[0];
+ else
+ ++p;
+ if (strcmp (p, "link") == 0) {
+ while (getopt (argc, argv, "") != -1)
+ usage ();
+ argc -= optind;
+ argv += optind;
+ if (argc != 2)
+ usage ();
+ linkf = link;
+ exit (linkit (argv[0], argv[1], 0));
+ }

  while ((ch = getopt(argc, argv, "Ffhns")) != -1)
  switch (ch) {

Reply | Threaded
Open this post in threaded view
|

Re: Patch to add link (SUSv2) utility

Andrés Delfino
Also note that ln(1) man page should be updated, since it is quite
different than FreeBSD's one, I didn't do it. I don't know too much
English, :P

On 9/5/06, AndrC)s <[hidden email]> wrote:

> This patch lets ln(1) handle link(1), just like in FreeBSD. In fact, I
> took all the lines I added from FreeBSD's ln. I don't know if one
> needs to add the license notice for those lines.
>
> http://www.opengroup.org/onlinepubs/000095399/utilities/link.html
>
> PS: If you are fine with this, I'll send unlink(1) patch too.
>
> Index: src/bin/ln/ln.c
> ===================================================================
> RCS file: /cvs/src/bin/ln/ln.c,v
> retrieving revision 1.14
> diff -u -r1.14 ln.c
> --- src/bin/ln/ln.c     25 Apr 2006 04:38:26 -0000      1.14
> +++ src/bin/ln/ln.c     5 Sep 2006 13:04:19 -0000
> @@ -70,7 +70,28 @@
>  {
>         struct stat sb;
>         int ch, exitval;
> -       char *sourcedir;
> +       char *p, *sourcedir;
> +
> +       /*
> +        * Test for the special case where the utility is called as
> +        * "link", for which the functionality provided is greatly
> +        * simplified.
> +        */
> +
> +       if ((p = strrchr (argv[0], '/')) == NULL)
> +               p = argv[0];
> +       else
> +               ++p;
> +       if (strcmp (p, "link") == 0) {
> +               while (getopt (argc, argv, "") != -1)
> +                       usage ();
> +               argc -= optind;
> +               argv += optind;
> +               if (argc != 2)
> +                       usage ();
> +               linkf = link;
> +               exit (linkit (argv[0], argv[1], 0));
> +       }
>
>         while ((ch = getopt(argc, argv, "Ffhns")) != -1)
>                 switch (ch) {
>


--
AndrC)s Delfino

Reply | Threaded
Open this post in threaded view
|

Re: Patch to add link (SUSv2) utility

Otto Moerbeek
In reply to this post by Andrés Delfino
On Tue, 5 Sep 2006, AndrC)s wrote:

> This patch lets ln(1) handle link(1), just like in FreeBSD. In fact, I
> took all the lines I added from FreeBSD's ln. I don't know if one
> needs to add the license notice for those lines.
>
> http://www.opengroup.org/onlinepubs/000095399/utilities/link.html
>
> PS: If you are fine with this, I'll send unlink(1) patch too.

It's a bad time in the release cycle now. Developers (and users as
well) should be testing, testing.

Please resend after tree thaw. And include usage() and man page
updates.

        -Otto

>
> Index: src/bin/ln/ln.c
> ===================================================================
> RCS file: /cvs/src/bin/ln/ln.c,v
> retrieving revision 1.14
> diff -u -r1.14 ln.c
> --- src/bin/ln/ln.c 25 Apr 2006 04:38:26 -0000 1.14
> +++ src/bin/ln/ln.c 5 Sep 2006 13:04:19 -0000
> @@ -70,7 +70,28 @@
> {
> struct stat sb;
> int ch, exitval;
> - char *sourcedir;
> + char *p, *sourcedir;
> +
> + /*
> + * Test for the special case where the utility is called as
> + * "link", for which the functionality provided is greatly
> + * simplified.
> + */
> +
> + if ((p = strrchr (argv[0], '/')) == NULL)
> + p = argv[0];
> + else
> + ++p;
> + if (strcmp (p, "link") == 0) {
> + while (getopt (argc, argv, "") != -1)
> + usage ();
> + argc -= optind;
> + argv += optind;
> + if (argc != 2)
> + usage ();
> + linkf = link;
> + exit (linkit (argv[0], argv[1], 0));
> + }
>
> while ((ch = getopt(argc, argv, "Ffhns")) != -1)
> switch (ch) {

Reply | Threaded
Open this post in threaded view
|

Re: Patch to add link (SUSv2) utility

Andrés Delfino
Got it :)

On 9/5/06, Otto Moerbeek <[hidden email]> wrote:

>
> On Tue, 5 Sep 2006, AndrC)s wrote:
>
> > This patch lets ln(1) handle link(1), just like in FreeBSD. In fact, I
> > took all the lines I added from FreeBSD's ln. I don't know if one
> > needs to add the license notice for those lines.
> >
> > http://www.opengroup.org/onlinepubs/000095399/utilities/link.html
> >
> > PS: If you are fine with this, I'll send unlink(1) patch too.
>
> It's a bad time in the release cycle now. Developers (and users as
> well) should be testing, testing.
>
> Please resend after tree thaw. And include usage() and man page
> updates.
>
>         -Otto
>
> >
> > Index: src/bin/ln/ln.c
> > ===================================================================
> > RCS file: /cvs/src/bin/ln/ln.c,v
> > retrieving revision 1.14
> > diff -u -r1.14 ln.c
> > --- src/bin/ln/ln.c   25 Apr 2006 04:38:26 -0000      1.14
> > +++ src/bin/ln/ln.c   5 Sep 2006 13:04:19 -0000
> > @@ -70,7 +70,28 @@
> > {
> >       struct stat sb;
> >       int ch, exitval;
> > -     char *sourcedir;
> > +     char *p, *sourcedir;
> > +
> > +     /*
> > +      * Test for the special case where the utility is called as
> > +      * "link", for which the functionality provided is greatly
> > +      * simplified.
> > +      */
> > +
> > +     if ((p = strrchr (argv[0], '/')) == NULL)
> > +             p = argv[0];
> > +     else
> > +             ++p;
> > +     if (strcmp (p, "link") == 0) {
> > +             while (getopt (argc, argv, "") != -1)
> > +                     usage ();
> > +             argc -= optind;
> > +             argv += optind;
> > +             if (argc != 2)
> > +                     usage ();
> > +             linkf = link;
> > +             exit (linkit (argv[0], argv[1], 0));
> > +     }
> >
> >       while ((ch = getopt(argc, argv, "Ffhns")) != -1)
> >               switch (ch) {
> >
> >
>


--
AndrC)s Delfino