/[smeserver]/rpms/initscripts/sme7/initscripts-kmodule.patch
ViewVC logotype

Contents of /rpms/initscripts/sme7/initscripts-kmodule.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Fri Sep 12 03:08:02 2008 UTC (15 years, 8 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Import of initscripts-7.93.33-1.centos4.src.rpm

1 Index: kmodule.c
2 ===================================================================
3 RCS file: /usr/local/CVS/initscripts/src/kmodule.c,v
4 retrieving revision 1.1.4.2
5 retrieving revision 1.1.4.3
6 diff -u -r1.1.4.2 -r1.1.4.3
7 --- initscripts/src/kmodule.c 7 Dec 2004 16:01:48 -0000 1.1.4.2
8 +++ initscripts/src/kmodule.c 10 Sep 2007 17:37:00 -0000 1.1.4.3
9 @@ -10,7 +10,7 @@
10 */
11
12 #include <ctype.h>
13 -#include <ftw.h>
14 +#include <fcntl.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 @@ -19,35 +19,39 @@
19
20 #include <popt.h>
21
22 +#include <sys/mman.h>
23 #include <sys/utsname.h>
24
25 #include <kudzu/kudzu.h>
26
27
28 -/* HACK. This is so not thread-safe. */
29 -static char mod_name[100], cmod_name[100];
30 -
31 -static int isModule(const char *filename, const struct stat *sb, int flag) {
32 - char *fname = basename(filename);
33 - if ((!strcmp(fname,mod_name) || !strcmp(fname,cmod_name))) {
34 - return 1;
35 - }
36 - return 0;
37 -}
38 -
39 -
40 int isAvailable(char *modulename)
41 {
42 struct utsname utsbuf;
43 - char path[512];
44 + struct stat sbuf;
45 + char path[512], mod_name[100];
46 + char *buf;
47 + int fd;
48
49 uname(&utsbuf);
50 - snprintf(mod_name,100,"%s.ko",modulename);
51 - snprintf(cmod_name,100,"%s.ko.gz",modulename);
52 - snprintf(path,512,"/lib/modules/%s/kernel",utsbuf.release);
53 - /* Do not set the third argument of this function to < 6. Blarg. */
54 - if (ftw(path,isModule,15) == 1) {
55 - return 1;
56 + snprintf(path,512,"/lib/modules/%s/modules.dep",utsbuf.release);
57 + if (!stat(path,&sbuf)) {
58 + fd = open(path, O_RDONLY);
59 + buf = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0);
60 + if (!buf || buf == MAP_FAILED)
61 + return 0;
62 + close(fd);
63 + snprintf(mod_name,100,"/%s.ko:", modulename);
64 + if (strstr(buf, mod_name)) {
65 + munmap(buf, sbuf.st_size);
66 + return 1;
67 + }
68 + snprintf(mod_name,100,"/%s.ko.gz:", modulename);
69 + if (strstr(buf, mod_name)) {
70 + munmap(buf, sbuf.st_size);
71 + return 1;
72 + }
73 + munmap(buf,sbuf.st_size);
74 }
75 return 0;
76 }

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed