initial checkin of new hdw-linux development cvs repository
[hdw-linux/hdw-linux.git] / misc / crossbuild / fake_utsname / fake_utsname.c
1 /* fake_utsname.o
2  *
3  * author: hackbard@hackdaworld.dyndns.org
4  *
5  */
6
7 /* what for:
8  *
9  * fake the machine type discovered by "uname -m" call.
10  * this is possibly needed by some crossbuilds, where packages try to determine
11  * the host or target architecture with the help of uname output.
12  *
13  * usage:
14  *
15  * insmod fake_utsname.o mname="<machine_type>"
16  * where <machine_type> could be:
17  * sparc64
18  * i386
19  * etc ...
20  */
21
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/utsname.h>
25 #include <linux/string.h>
26
27 #define UTSNAME_M_LEN 65
28
29 /* if there is no define ... */
30 #ifndef FAKE_M_UTSNAME
31 #define FAKE_M_UTSNAME "sparc64"
32 #endif
33
34 MODULE_LICENSE("GPL v2");
35
36 char mname_orig[UTSNAME_M_LEN];
37 char *mname=FAKE_M_UTSNAME;
38
39 MODULE_PARM(mname,"s");
40
41 int init_module(void) {
42  int i;
43
44  memset(mname_orig,0,UTSNAME_M_LEN);
45  memcpy(mname_orig,system_utsname.machine,sizeof(system_utsname.machine));
46  i=strlen(mname);
47  memcpy(system_utsname.machine,mname,i);
48  memset(system_utsname.machine+i,0,UTSNAME_M_LEN-i);
49
50  return(0);
51 }
52
53 void cleanup_module(void) {
54
55  memcpy(system_utsname.machine,mname_orig,UTSNAME_M_LEN);
56
57 }