"Fossies" - the Fresh Open Source Software Archive

Member "dosfstools-4.2/src/blkdev/linux_version.c" (31 Jan 2021, 433 Bytes) of package /linux/misc/dosfstools-4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "linux_version.c" see the Fossies "Dox" file reference documentation.

    1 #include <stdio.h>
    2 #include <sys/utsname.h>
    3 
    4 #include "linux_version.h"
    5 
    6 int get_linux_version (void)
    7 {
    8     static int kver = -1;
    9     struct utsname uts;
   10     int major = 0;
   11     int minor = 0;
   12     int teeny = 0;
   13     int n;
   14 
   15     if (kver != -1)
   16         return kver;
   17     if (uname (&uts))
   18         return kver = 0;
   19 
   20     n = sscanf(uts.release, "%d.%d.%d", &major, &minor, &teeny);
   21     if (n < 1 || n > 3)
   22         return kver = 0;
   23 
   24     return kver = KERNEL_VERSION(major, minor, teeny);
   25 }