74 |
|
#endif |
75 |
|
|
76 |
|
#ifdef SOLARIS |
77 |
< |
const char *get_svr_from_bsd(const char *bsd){ |
77 |
> |
const char *sg_get_svr_from_bsd(const char *bsd){ |
78 |
|
#ifdef HAVE_LIBDEVINFO_H |
79 |
|
mapping_t *map_ptr; |
80 |
|
for(map_ptr = mapping; map_ptr != NULL; map_ptr = map_ptr->next) |
85 |
|
#endif |
86 |
|
|
87 |
|
#if defined(SOLARIS) && defined(HAVE_LIBDEVINFO_H) |
88 |
< |
void add_mapping(char *bsd, char *svr){ |
88 |
> |
static void add_mapping(char *bsd, char *svr){ |
89 |
|
mapping_t *map_ptr; |
90 |
|
mapping_t *map_end_ptr; |
91 |
|
|
117 |
|
return; |
118 |
|
} |
119 |
|
|
120 |
< |
char *read_dir(char *disk_path){ |
120 |
> |
|
121 |
> |
static char *read_dir(char *disk_path){ |
122 |
|
DIR *dirp; |
123 |
|
struct dirent *dp; |
124 |
|
struct stat stbuf; |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
< |
|
163 |
< |
int get_alias(char *alias){ |
163 |
> |
static int get_alias(char *alias){ |
164 |
|
char file[MAXPATHLEN]; |
165 |
|
di_node_t root_node; |
166 |
|
di_node_t node; |
181 |
|
minor_name = di_minor_name(minor); |
182 |
|
strcpy(tmpnode, alias); |
183 |
|
sprintf(tmpnode, "%s%d", tmpnode, instance); |
184 |
< |
strlcpy(file, "/devices", sizeof file); |
185 |
< |
strlcat(file, phys_path, sizeof file); |
186 |
< |
strlcat(file, ":", sizeof file); |
187 |
< |
strlcat(file, minor_name, sizeof file); |
184 |
> |
sg_strlcpy(file, "/devices", sizeof file); |
185 |
> |
sg_strlcat(file, phys_path, sizeof file); |
186 |
> |
sg_strlcat(file, ":", sizeof file); |
187 |
> |
sg_strlcat(file, minor_name, sizeof file); |
188 |
|
value = read_dir(file); |
189 |
|
if (value != NULL){ |
190 |
|
add_mapping(tmpnode, value); |
201 |
|
|
202 |
|
|
203 |
|
#define BIG_ENOUGH 512 |
204 |
< |
int build_mapping(){ |
204 |
> |
static int build_mapping(){ |
205 |
|
char device_name[BIG_ENOUGH]; |
206 |
|
int x; |
207 |
|
kstat_ctl_t *kc; |
260 |
|
|
261 |
|
|
262 |
|
|
263 |
< |
char *f_read_line(FILE *f, const char *string){ |
263 |
> |
char *sg_f_read_line(FILE *f, const char *string){ |
264 |
|
/* Max line length. 8k should be more than enough */ |
265 |
|
static char line[8192]; |
266 |
|
|
273 |
|
return NULL; |
274 |
|
} |
275 |
|
|
276 |
< |
char *get_string_match(char *line, regmatch_t *match){ |
276 |
> |
char *sg_get_string_match(char *line, regmatch_t *match){ |
277 |
|
int len=match->rm_eo - match->rm_so; |
278 |
|
char *match_string=malloc(len+1); |
279 |
|
|
305 |
|
} |
306 |
|
#endif |
307 |
|
|
308 |
– |
#ifndef HAVE_STRLCPY |
308 |
|
/* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ |
309 |
|
|
310 |
|
/* |
328 |
|
* will be copied. Always NUL terminates (unless siz == 0). |
329 |
|
* Returns strlen(src); if retval >= siz, truncation occurred. |
330 |
|
*/ |
331 |
< |
size_t strlcpy(char *dst, const char *src, size_t siz){ |
331 |
> |
size_t sg_strlcpy(char *dst, const char *src, size_t siz){ |
332 |
|
register char *d = dst; |
333 |
|
register const char *s = src; |
334 |
|
register size_t n = siz; |
351 |
|
|
352 |
|
return(s - src - 1); /* count does not include NUL */ |
353 |
|
} |
355 |
– |
#endif |
354 |
|
|
357 |
– |
#ifndef HAVE_STRLCAT |
355 |
|
/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */ |
356 |
|
|
357 |
|
/* |
377 |
|
* Returns strlen(src) + MIN(siz, strlen(initial dst)). |
378 |
|
* If retval >= siz, truncation occurred. |
379 |
|
*/ |
380 |
< |
size_t strlcat(char *dst, const char *src, size_t siz){ |
380 |
> |
size_t sg_strlcat(char *dst, const char *src, size_t siz){ |
381 |
|
register char *d = dst; |
382 |
|
register const char *s = src; |
383 |
|
register size_t n = siz; |
403 |
|
return(dlen + (s - src)); /* count does not include NUL */ |
404 |
|
} |
405 |
|
|
406 |
< |
#endif |
410 |
< |
|
411 |
< |
char *update_string(char **dest, const char *src) { |
406 |
> |
char *sg_update_string(char **dest, const char *src) { |
407 |
|
char *new; |
408 |
|
|
409 |
|
new = realloc(*dest, strlen(src) + 1); |
416 |
|
return new; |
417 |
|
} |
418 |
|
|
419 |
< |
long long get_ll_match(char *line, regmatch_t *match){ |
419 |
> |
long long sg_get_ll_match(char *line, regmatch_t *match){ |
420 |
|
char *ptr; |
421 |
|
long long num; |
422 |
|
|
427 |
|
} |
428 |
|
|
429 |
|
#if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD) |
430 |
< |
kvm_t *get_kvm() { |
430 |
> |
kvm_t *sg_get_kvm() { |
431 |
|
static kvm_t *kvmd = NULL; |
432 |
|
|
433 |
|
if (kvmd != NULL) { |
439 |
|
} |
440 |
|
|
441 |
|
/* Can't think of a better name for this function */ |
442 |
< |
kvm_t *get_kvm2() { |
442 |
> |
kvm_t *sg_get_kvm2() { |
443 |
|
static kvm_t *kvmd2 = NULL; |
444 |
|
|
445 |
|
if (kvmd2 != NULL) { |
452 |
|
#endif |
453 |
|
|
454 |
|
#if defined(NETBSD) || defined(OPENBSD) |
455 |
< |
struct uvmexp *get_uvmexp() { |
455 |
> |
struct uvmexp *sg_get_uvmexp() { |
456 |
|
int mib[2]; |
457 |
|
size_t size; |
458 |
|
static struct uvmexp *uvm = NULL; |
479 |
|
} |
480 |
|
#endif |
481 |
|
|
482 |
< |
int statgrab_init(){ |
482 |
> |
int sg_init(){ |
483 |
|
#if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD) |
484 |
< |
{ |
485 |
< |
kvm_t *kvmd = get_kvm(); |
491 |
< |
if (kvmd == NULL) return 1; |
484 |
> |
if (sg_get_kvm() == NULL) { |
485 |
> |
return 1; |
486 |
|
} |
487 |
< |
{ |
488 |
< |
kvm_t *kvmd2 = get_kvm2(); |
495 |
< |
if (kvmd2 == NULL) return 1; |
487 |
> |
if (sg_get_kvm2() == NULL) { |
488 |
> |
return 1; |
489 |
|
} |
490 |
|
#endif |
491 |
|
#if defined(NETBSD) || defined(OPENBSD) |
492 |
< |
{ |
493 |
< |
/* This should always succeed, but it seems that on some |
494 |
< |
* versions of NetBSD the first call to get_uvmexp will return |
495 |
< |
* a non-filled-in structure; this is a workaround for that. |
496 |
< |
*/ |
504 |
< |
struct uvmexp *uvm = get_uvmexp(); |
505 |
< |
if (uvm == NULL) return 1; |
506 |
< |
} |
492 |
> |
/* This should always succeed, but it seems that on some |
493 |
> |
* versions of NetBSD the first call to get_uvmexp will return |
494 |
> |
* a non-filled-in structure; this is a workaround for that. |
495 |
> |
*/ |
496 |
> |
if (sg_get_uvmexp() == NULL) return 1; |
497 |
|
#endif |
498 |
|
#ifdef SOLARIS |
499 |
|
/* On solaris 7, this will fail if you are not root. But, everything |
507 |
|
return 0; |
508 |
|
} |
509 |
|
|
510 |
< |
int statgrab_drop_privileges() { |
510 |
> |
int sg_drop_privileges() { |
511 |
|
if (setegid(getgid()) != 0) return -1; |
512 |
|
if (seteuid(getuid()) != 0) return -1; |
513 |
|
return 0; |