• lsb_release interface

    From Corey@21:1/5 to All on Tue Nov 12 11:10:01 2024
    Hello

    Do you know in C language what's the better way to get the info like the output by lsb_release?

    $ lsb_release -cd
    Description: Ubuntu 22.04.3 LTS
    Codename: jammy


    i know there is system call. but is there a native way?

    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tomas@tuxteam.de@21:1/5 to Corey on Tue Nov 12 11:30:01 2024
    On Tue, Nov 12, 2024 at 10:08:18AM +0000, Corey wrote:
    Hello

    Do you know in C language what's the better way to get the info like the output by lsb_release?

    $ lsb_release -cd
    Description: Ubuntu 22.04.3 LTS
    Codename: jammy


    i know there is system call. but is there a native way?

    I don't think there is a special system call for that. Have you had a
    look at the command itself? It is a shell script, and looks pretty
    pedestrian to me (at first sight, granted).

    Cheers
    --
    t

    -----BEGIN PGP SIGNATURE-----

    iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZzMs9AAKCRAFyCz1etHa RrPcAJ9MIlL5RVgm0/1Aqct4DQ767cIA7gCeIv+ZvGk+PkXX1HdnitKhGfzIOww=
    =eDyB
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to tomas@tuxteam.de on Tue Nov 12 13:30:01 2024
    On Tue, Nov 12, 2024 at 11:24:59 +0100, tomas@tuxteam.de wrote:
    On Tue, Nov 12, 2024 at 10:08:18AM +0000, Corey wrote:
    Hello

    Do you know in C language what's the better way to get the info like the output by lsb_release?

    $ lsb_release -cd
    Description: Ubuntu 22.04.3 LTS
    Codename: jammy


    i know there is system call. but is there a native way?

    I don't think there is a special system call for that. Have you had a
    look at the command itself? It is a shell script, and looks pretty
    pedestrian to me (at first sight, granted).

    I think Corey might be confused about the term "system call".

    Most people use "system call" to mean an invocation of a subroutine
    within the kernel. These system calls are documented in section 2 of
    the man pages, so e.g. "read(2)" is a system call that reads bytes
    from an open file descriptor.

    For the official explanation of a system call, see <https://manpages.debian.org/bookworm/manpages/intro.2.en.html>
    or "man 2 intro" if you have this section installed locally.

    I *suspect* that Corey thought "system call" meant the use of the
    system(3) library function, which executes a shell command.

    As tomas points out, lsb_release is a relatively short shell script,
    and you can read it to see what it's doing. Ultimately, it's reading
    data from /etc/os-release (or /usr/lib/os-release), parsing it, and
    printing pieces of it.

    You could write a C program to do the same steps.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)