• Matt Domsch's avatar
    [PATCH] modules: add version and srcversion to sysfs · c988d2b2
    Matt Domsch authored
    This patch adds version and srcversion files to
    /sys/module/${modulename} containing the version and srcversion fields
    of the module's modinfo section (if present).
    
    /sys/module/e1000
    |-- srcversion
    `-- version
    
    This patch differs slightly from the version posted in January, as it
    now uses the new kstrdup() call in -mm.
    
    Why put this in sysfs?
    
    a) Tools like DKMS, which deal with changing out individual kernel
       modules without replacing the whole kernel, can behave smarter if they
       can tell the version of a given module.  The autoinstaller feature, for
       example, which determines if your system has a "good" version of a
       driver (i.e.  if the one provided by DKMS has a newer verson than that
       provided by the kernel package installed), and to automatically compile
       and install a newer version if DKMS has it but your kernel doesn't yet
       have that version.
    
    b) Because sysadmins manually, or with tools like DKMS, can switch out
       modules on the file system, you can't count on 'modinfo foo.ko', which
       looks at /lib/modules/${kernelver}/...  actually matching what is loaded
       into the kernel already.  Hence asking sysfs for this.
    
    c) as the unbind-driver-from-device work takes shape, it will be
       possible to rebind a driver that's built-in (no .ko to modinfo for the
       version) to a newly loaded module.  sysfs will have the
       currently-built-in version info, for comparison.
    
    d) tech support scripts can then easily grab the version info for what's
       running presently - a question I get often.
    
    There has been renewed interest in this patch on linux-scsi by driver
    authors.
    
    As the idea originated from GregKH, I leave his Signed-off-by: intact,
    though the implementation is nearly completely new.  Compiled and run on
    x86 and x86_64.
    
    From: Matthew Dobson <colpatch@us.ibm.com>
    
          build fix
    
    From: Thierry Vignaud <tvignaud@mandriva.com>
    
          build fix
    
    From: Matthew Dobson <colpatch@us.ibm.com>
    
          warning fix
    Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
    Signed-off-by: default avatarMatt Domsch <Matt_Domsch@dell.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    c988d2b2
module.c 56 KB