11.01.2013 Views

IBM AIX Continuous Availability Features - IBM Redbooks

IBM AIX Continuous Availability Features - IBM Redbooks

IBM AIX Continuous Availability Features - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

return 0;<br />

}else{<br />

printf("[%s] not loaded with ERROR=%d\n",g_binpath,errno);<br />

return 1;<br />

}<br />

}<br />

if (!(strcmp("--unload",*(argv+1)))){<br />

ADD_LIBPATH();<br />

if (sysconfig(SYS_QUERYLOAD, &g_cfg_load, sizeof(struct \\<br />

cfg_load))||g_cfg_load.kmid){<br />

printf("[%s] found with mid=[%d]\n",g_binpath,g_cfg_load.kmid);<br />

/*<br />

* Unloaded the loaded kernel extension<br />

*/<br />

if (sysconfig(SYS_KULOAD, &g_cfg_load, sizeof(struct cfg_load))== 0){<br />

printf("[%s] unloaded successfully\n",g_binpath);<br />

return 0;<br />

}else{<br />

printf("[%s] not unloaded with error=[%d]\n",g_binpath,errno);<br />

return 1;<br />

}<br />

}else{<br />

printf("[%s] currently not loaded, nothing to unload\n",g_binpath);<br />

return 1;<br />

}<br />

}<br />

/*<br />

* Invalid second Argument<br />

*/<br />

printf("Usage: service --load|--unload Kernel_Entension [Libpath]\n");<br />

return 1;<br />

Try to load the kernel extension and call it first with a protection gate, and then without an<br />

appropriate protection gate (that is, without KKEY_VMM) by using KKEY_VMM.<br />

Note: The second iteration will cause the kernel to crash.<br />

To view the output of the kernel extension (system call), you need console access. All output<br />

will go to the hardware console when you use printf() in kernel mode. Compile the program<br />

using the command shown in Example 3-26.<br />

Example 3-26 Compile the program<br />

# make<br />

/usr/vac/bin/cc -q64 -o myprog myprog.c -bI:kkey_set.exp<br />

/usr/vac/bin/cc -o service service.c<br />

/usr/vac/bin/cc -q64 -D_KERNEL -D_KERNSYS -D_64BIT_KERNEL -D__64BIT__ -o<br />

kkey_set64.o -c kkey_set.c<br />

"kkey_set.c": 1506-312 (W) Compiler internal name __64BIT__ has been defined as a<br />

macro.<br />

ld -b64 -o kkey_set64 kkey_set64.o -e kkey_test_init -bE:kkey_set.exp<br />

-bI:/usr/lib/kernex.exp -lcsys<br />

Target "all" is up to date.<br />

Chapter 3. <strong>AIX</strong> advanced continuous availability tools and features 95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!