- 论坛徽章:
- 0
|
一个关于SGI机身号的讨论
# cc -o change-sid change-sid.c -lmld
# sysinfo
System ID:
de ad 12 34 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
rodent 44# ./change-sid
hexadecimal system id seems to be dead1234
rodent 45# ./change-sid 12345678
rodent 46# ./change-sid
hexadecimal system id seems to be 12345678
rodent 47# sysinfo
System ID:
12 34 56 78 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-- change-sid.c --
/*
* change system id on IRIX 5.3 - only minimally tested on one machine
* consider this pre-pre-alpha - USE AT YOUR OWN RISK
* compile by -- cc -o change-sid change-sid.c -lmld
* placed in the public domain by the author - Nov 1996
* Mark Henderson <mch@squirrel.com>;
*/
#include <fcntl.h>;
#include <unistd.h>;
#include <stdio.h>;
#include <sys/types.h>;
#include <sys/uio.h>;
#include <nlist.h>;
struct nlist nl[2];
main(argc,argv)
int argc;
char *argv[];
{
int kmem;
int just_read = 0;
unsigned int new_id, cur_id;
off_t where;
just_read = (argc <= 1);
if (argc >; 1)
new_id = strtoul(argv[1], NULL, 16);
if ((kmem = open("/dev/kmem", O_RDWR)) < 0) {
fprintf(stderr, "cannot open /dev/kmem\n"
exit(1);
}
nl[0].n_name="eccf_addr";
nl[1].n_name = NULL;
if (nlist("/unix", nl) < 0) {
fprintf(stderr, "cannot read namelist out of /dev/ksyms\n"
exit(1);
}
if ((where = nl[0].n_value) == 0) {
fprintf(stderr, "unknown kernel variable eccf_addr\n"
exit(1);
}
if (lseek(kmem, where + 4, SEEK_SET) == (-1)) {
fprintf(stderr, "lseek on /dev/kmem failed\n"
exit(1);
}
if (!just_read) {
if (write (kmem, &new_id, 4) < 4) {
fprintf(stderr, "write to /dev/kmem failed\n"
exit(1);
}
}
else {
if (read(kmem, &cur_id, 4) < 4) {
fprintf(stderr, "read failed\n"
exit(1);
}
printf("hexadecimal system id seems to be %08x\n", cur_id);
}
close(kmem);
exit(0);
} |
|