ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/tools.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/tools.c (file contents):
Revision 1.31 by tdb, Mon Feb 16 14:55:32 2004 UTC vs.
Revision 1.35 by tdb, Sun Apr 4 22:48:50 2004 UTC

# Line 34 | Line 34
34   #ifdef ALLBSD
35   #include <fcntl.h>
36   #endif
37 < #if defined(FREEBSD) || defined(DFBSD)
37 > #if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD)
38   #include <kvm.h>
39 + #include <paths.h>
40   #endif
41   #if defined(NETBSD) || defined(OPENBSD)
42   #include <uvm/uvm_extern.h>
# Line 420 | Line 421 | long long get_ll_match(char *line, regmatch_t *match){
421          return num;
422   }
423  
424 < #if defined(FREEBSD) || defined(DFBSD)
424 > #if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD)
425   kvm_t *get_kvm() {
426          static kvm_t *kvmd = NULL;
427  
# Line 431 | Line 432 | kvm_t *get_kvm() {
432          kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, NULL);
433          return kvmd;
434   }
435 +
436 + /* Can't think of a better name for this function */
437 + kvm_t *get_kvm2() {
438 +        static kvm_t *kvmd2 = NULL;
439 +
440 +        if (kvmd2 != NULL) {
441 +                return kvmd2;
442 +        }
443 +
444 +        kvmd2 = kvm_openfiles(_PATH_DEVNULL, _PATH_DEVNULL, NULL, O_RDONLY, NULL);
445 +        return kvmd2;
446 + }
447   #endif
448  
449   #if defined(NETBSD) || defined(OPENBSD)
# Line 460 | Line 473 | struct uvmexp *get_uvmexp() {
473   #endif
474  
475   int statgrab_init(){
476 < #if defined(FREEBSD) || defined(DFBSD)
476 > #if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD)
477          {
478                  kvm_t *kvmd = get_kvm();
479                  if (kvmd == NULL) return 1;
480 +        }
481 +        {
482 +                kvm_t *kvmd2 = get_kvm2();
483 +                if (kvmd2 == NULL) return 1;
484 +        }
485 + #endif
486 + #if defined(NETBSD) || defined(OPENBSD)
487 +        {
488 +                /* This should always succeed, but it seems that on some
489 +                 * versions of NetBSD the first call to get_uvmexp will return
490 +                 * a non-filled-in structure; this is a workaround for that.
491 +                 */
492 +                struct uvmexp *uvm = get_uvmexp();
493 +                if (uvm == NULL) return 1;
494          }
495   #endif
496   #ifdef SOLARIS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines