Lack of system_utsname in recent kernels may prevent some systemtap programs from compiling

Marcin Krol admin@domeny.pl
Sat Dec 1 10:53:00 GMT 2007


Hello everyone,

I just realized I should rather correct this example from tutorial, 
since linux/utsname.h has changed.

However, I still don't get why I can't compile this updated example, 
since /usr/include/linux/utsname.h does include relevant structures:

struct new_utsname {
        char sysname[65];
        char nodename[65];
        char release[65];
        char version[65];
        char machine[65];
        char domainname[65];
};


% cat embed-C.stp
%{
#include <linux/utsname.h>
%}
function utsname:string (field:long)
%{
  if (down_read_trylock (& uts_sem))
    {
      const char *f =
         (THIS->field == 0 ? new_utsname.sysname :
          THIS->field == 1 ? new_utsname.nodename :
          THIS->field == 2 ? new_utsname.release :
          THIS->field == 3 ? new_utsname.version :
          THIS->field == 4 ? new_utsname.machine :
          THIS->field == 5 ? new_utsname.domainname : "");
      strlcpy (THIS->__retvalue, f, MAXSTRINGLEN);
      up_read (& uts_sem);
    }
%}

probe begin
{
  printf ("%s %s\n", utsname(0), utsname(2))
  exit ()
}




% stap -g -v -v embed-C.stp

...

/tmp/stapVY7M4t/stap_66839fd49ac82638003fd877311d02f2_848.c: In function 
'function_utsname':
/tmp/stapVY7M4t/stap_66839fd49ac82638003fd877311d02f2_848.c:145: error: 
'new_utsname' undeclared (first use in this function)
/tmp/stapVY7M4t/stap_66839fd49ac82638003fd877311d02f2_848.c:145: error: 
(Each undeclared identifier is reported only once
/tmp/stapVY7M4t/stap_66839fd49ac82638003fd877311d02f2_848.c:145: error: 
for each function it appears in.)
make[1]: *** 
[/tmp/stapVY7M4t/stap_66839fd49ac82638003fd877311d02f2_848.o] Error 1




--
Marcin Krol




More information about the Systemtap mailing list