summaryrefslogtreecommitdiffstats
path: root/lib/mountlist.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-03-19 12:59:38 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-03-19 12:59:38 +0000
commit8535da68ef4fdd8ccebc9a0fe72bf3bf61e71f65 (patch)
treeade919c5add626d726a0da292fe0b798590aa173 /lib/mountlist.c
parent9b11e0b65227e4e92b5d3f49a45fa7928dc7c113 (diff)
downloadmonitoring-plugins-8535da68ef4fdd8ccebc9a0fe72bf3bf61e71f65.tar.gz
check_disk working with mountlist.c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@439 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/mountlist.c')
-rw-r--r--lib/mountlist.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/lib/mountlist.c b/lib/mountlist.c
index b667c443..d171858a 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -35,9 +35,9 @@ void free ();
35#ifndef strstr 35#ifndef strstr
36char *strstr (); 36char *strstr ();
37#endif 37#endif
38char *xmalloc (); 38/* char *xmalloc (); */
39char *xrealloc (); 39/* char *realloc (); */
40char *xstrdup (); 40/* char *xstrdup (); */
41 41
42#include <errno.h> 42#include <errno.h>
43#ifndef errno 43#ifndef errno
@@ -307,10 +307,10 @@ read_filesystem_list (int need_fs_type)
307 return NULL; 307 return NULL;
308 for (p = mntlist; p; p = p->next) { 308 for (p = mntlist; p; p = p->next) {
309 mnt = p->ment; 309 mnt = p->ment;
310 me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry)); 310 me = (struct mount_entry*) malloc(sizeof (struct mount_entry));
311 me->me_devname = xstrdup(mnt->mnt_fsname); 311 me->me_devname = strdup(mnt->mnt_fsname);
312 me->me_mountdir = xstrdup(mnt->mnt_dir); 312 me->me_mountdir = strdup(mnt->mnt_dir);
313 me->me_type = xstrdup(mnt->mnt_type); 313 me->me_type = strdup(mnt->mnt_type);
314 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 314 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
315 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 315 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
316 me->me_dev = -1; 316 me->me_dev = -1;
@@ -334,10 +334,10 @@ read_filesystem_list (int need_fs_type)
334 334
335 while ((mnt = getmntent (fp))) 335 while ((mnt = getmntent (fp)))
336 { 336 {
337 me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); 337 me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
338 me->me_devname = xstrdup (mnt->mnt_fsname); 338 me->me_devname = strdup (mnt->mnt_fsname);
339 me->me_mountdir = xstrdup (mnt->mnt_dir); 339 me->me_mountdir = strdup (mnt->mnt_dir);
340 me->me_type = xstrdup (mnt->mnt_type); 340 me->me_type = strdup (mnt->mnt_type);
341 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 341 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
342 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 342 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
343 devopt = strstr (mnt->mnt_opts, "dev="); 343 devopt = strstr (mnt->mnt_opts, "dev=");
@@ -373,9 +373,9 @@ read_filesystem_list (int need_fs_type)
373 { 373 {
374 char *fs_type = fsp_to_string (fsp); 374 char *fs_type = fsp_to_string (fsp);
375 375
376 me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); 376 me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
377 me->me_devname = xstrdup (fsp->f_mntfromname); 377 me->me_devname = strdup (fsp->f_mntfromname);
378 me->me_mountdir = xstrdup (fsp->f_mntonname); 378 me->me_mountdir = strdup (fsp->f_mntonname);
379 me->me_type = fs_type; 379 me->me_type = fs_type;
380 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 380 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
381 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 381 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
@@ -398,9 +398,9 @@ read_filesystem_list (int need_fs_type)
398 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY, 398 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
399 (char *) 0))) 399 (char *) 0)))
400 { 400 {
401 me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); 401 me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
402 me->me_devname = xstrdup (fsd.fd_req.devname); 402 me->me_devname = strdup (fsd.fd_req.devname);
403 me->me_mountdir = xstrdup (fsd.fd_req.path); 403 me->me_mountdir = strdup (fsd.fd_req.path);
404 me->me_type = gt_names[fsd.fd_req.fstype]; 404 me->me_type = gt_names[fsd.fd_req.fstype];
405 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 405 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
406 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 406 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
@@ -458,10 +458,10 @@ read_filesystem_list (int need_fs_type)
458 continue; 458 continue;
459 459
460 if (strcmp (d->d_name, ".") == 0) 460 if (strcmp (d->d_name, ".") == 0)
461 name = xstrdup ("/"); 461 name = strdup ("/");
462 else 462 else
463 { 463 {
464 name = xmalloc (1 + strlen (d->d_name) + 1); 464 name = malloc (1 + strlen (d->d_name) + 1);
465 name[0] = '/'; 465 name[0] = '/';
466 strcpy (name + 1, d->d_name); 466 strcpy (name + 1, d->d_name);
467 } 467 }
@@ -470,7 +470,7 @@ read_filesystem_list (int need_fs_type)
470 { 470 {
471 struct rootdir_entry *re; 471 struct rootdir_entry *re;
472 472
473 re = (struct rootdir_entry *) xmalloc (sizeof (struct rootdir_entry)); 473 re = (struct rootdir_entry *) malloc (sizeof (struct rootdir_entry));
474 re->name = name; 474 re->name = name;
475 re->dev = statbuf.st_dev; 475 re->dev = statbuf.st_dev;
476 re->ino = statbuf.st_ino; 476 re->ino = statbuf.st_ino;
@@ -496,10 +496,10 @@ read_filesystem_list (int need_fs_type)
496 if (re->dev == fi.dev && re->ino == fi.root) 496 if (re->dev == fi.dev && re->ino == fi.root)
497 break; 497 break;
498 498
499 me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); 499 me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
500 me->me_devname = xstrdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name); 500 me->me_devname = strdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
501 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name); 501 me->me_mountdir = strdup (re != NULL ? re->name : fi.fsh_name);
502 me->me_type = xstrdup (fi.fsh_name); 502 me->me_type = strdup (fi.fsh_name);
503 me->me_dev = fi.dev; 503 me->me_dev = fi.dev;
504 me->me_dummy = 0; 504 me->me_dummy = 0;
505 me->me_remote = (fi.flags & B_FS_IS_SHARED) != 0; 505 me->me_remote = (fi.flags & B_FS_IS_SHARED) != 0;
@@ -530,7 +530,7 @@ read_filesystem_list (int need_fs_type)
530 return (NULL); 530 return (NULL);
531 531
532 bufsize = (1 + numsys) * sizeof (struct statfs); 532 bufsize = (1 + numsys) * sizeof (struct statfs);
533 stats = (struct statfs *)xmalloc (bufsize); 533 stats = (struct statfs *)malloc (bufsize);
534 numsys = getfsstat (stats, bufsize, MNT_WAIT); 534 numsys = getfsstat (stats, bufsize, MNT_WAIT);
535 535
536 if (numsys < 0) 536 if (numsys < 0)
@@ -541,9 +541,9 @@ read_filesystem_list (int need_fs_type)
541 541
542 for (counter = 0; counter < numsys; counter++) 542 for (counter = 0; counter < numsys; counter++)
543 { 543 {
544 me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); 544 me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
545 me->me_devname = xstrdup (stats[counter].f_mntfromname); 545 me->me_devname = strdup (stats[counter].f_mntfromname);
546 me->me_mountdir = xstrdup (stats[counter].f_mntonname); 546 me->me_mountdir = strdup (stats[counter].f_mntonname);
547 me->me_type = mnt_names[stats[counter].f_type]; 547 me->me_type = mnt_names[stats[counter].f_type];
548 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 548 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
549 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 549 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
@@ -570,15 +570,15 @@ read_filesystem_list (int need_fs_type)
570 570
571 while (fread (&mnt, sizeof mnt, 1, fp) > 0) 571 while (fread (&mnt, sizeof mnt, 1, fp) > 0)
572 { 572 {
573 me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); 573 me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
574# ifdef GETFSTYP /* SVR3. */ 574# ifdef GETFSTYP /* SVR3. */
575 me->me_devname = xstrdup (mnt.mt_dev); 575 me->me_devname = strdup (mnt.mt_dev);
576# else 576# else
577 me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6); 577 me->me_devname = malloc (strlen (mnt.mt_dev) + 6);
578 strcpy (me->me_devname, "/dev/"); 578 strcpy (me->me_devname, "/dev/");
579 strcpy (me->me_devname + 5, mnt.mt_dev); 579 strcpy (me->me_devname + 5, mnt.mt_dev);
580# endif 580# endif
581 me->me_mountdir = xstrdup (mnt.mt_filsys); 581 me->me_mountdir = strdup (mnt.mt_filsys);
582 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ 582 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
583 me->me_type = ""; 583 me->me_type = "";
584# ifdef GETFSTYP /* SVR3. */ 584# ifdef GETFSTYP /* SVR3. */
@@ -589,7 +589,7 @@ read_filesystem_list (int need_fs_type)
589 589
590 if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1 590 if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
591 && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) 591 && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
592 me->me_type = xstrdup (typebuf); 592 me->me_type = strdup (typebuf);
593 } 593 }
594# endif 594# endif
595 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 595 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -618,10 +618,10 @@ read_filesystem_list (int need_fs_type)
618 struct mntent **mnttbl=getmnttbl(),**ent; 618 struct mntent **mnttbl=getmnttbl(),**ent;
619 for (ent=mnttbl;*ent;ent++) 619 for (ent=mnttbl;*ent;ent++)
620 { 620 {
621 me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); 621 me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
622 me->me_devname = xstrdup ( (*ent)->mt_resource); 622 me->me_devname = strdup ( (*ent)->mt_resource);
623 me->me_mountdir = xstrdup( (*ent)->mt_directory); 623 me->me_mountdir = strdup( (*ent)->mt_directory);
624 me->me_type = xstrdup ((*ent)->mt_fstype); 624 me->me_type = strdup ((*ent)->mt_fstype);
625 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 625 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
626 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 626 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
627 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ 627 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
@@ -679,10 +679,10 @@ read_filesystem_list (int need_fs_type)
679 { 679 {
680 while ((ret = getmntent (fp, &mnt)) == 0) 680 while ((ret = getmntent (fp, &mnt)) == 0)
681 { 681 {
682 me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); 682 me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
683 me->me_devname = xstrdup (mnt.mnt_special); 683 me->me_devname = strdup (mnt.mnt_special);
684 me->me_mountdir = xstrdup (mnt.mnt_mountp); 684 me->me_mountdir = strdup (mnt.mnt_mountp);
685 me->me_type = xstrdup (mnt.mnt_fstype); 685 me->me_type = strdup (mnt.mnt_fstype);
686 me->me_dummy = MNT_IGNORE (&mnt) != 0; 686 me->me_dummy = MNT_IGNORE (&mnt) != 0;
687 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 687 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
688 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ 688 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
@@ -714,7 +714,7 @@ read_filesystem_list (int need_fs_type)
714 714
715 /* Ask how many bytes to allocate for the mounted filesystem info. */ 715 /* Ask how many bytes to allocate for the mounted filesystem info. */
716 mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize); 716 mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize);
717 entries = xmalloc (bufsize); 717 entries = malloc (bufsize);
718 718
719 /* Get the list of mounted filesystems. */ 719 /* Get the list of mounted filesystems. */
720 mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries); 720 mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
@@ -734,7 +734,7 @@ read_filesystem_list (int need_fs_type)
734 /* Prepend the remote pathname. */ 734 /* Prepend the remote pathname. */
735 host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off; 735 host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
736 path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off; 736 path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
737 me->me_devname = xmalloc (strlen (host) + strlen (path) + 2); 737 me->me_devname = malloc (strlen (host) + strlen (path) + 2);
738 strcpy (me->me_devname, host); 738 strcpy (me->me_devname, host);
739 strcat (me->me_devname, ":"); 739 strcat (me->me_devname, ":");
740 strcat (me->me_devname, path); 740 strcat (me->me_devname, path);
@@ -742,11 +742,11 @@ read_filesystem_list (int need_fs_type)
742 else 742 else
743 { 743 {
744 me->me_remote = 0; 744 me->me_remote = 0;
745 me->me_devname = xstrdup (thisent + 745 me->me_devname = strdup (thisent +
746 vmp->vmt_data[VMT_OBJECT].vmt_off); 746 vmp->vmt_data[VMT_OBJECT].vmt_off);
747 } 747 }
748 me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); 748 me->me_mountdir = strdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
749 me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); 749 me->me_type = strdup (fstype_to_string (vmp->vmt_gfstype));
750 options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off; 750 options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
751 ignore = strstr (options, "ignore"); 751 ignore = strstr (options, "ignore");
752 me->me_dummy = (ignore 752 me->me_dummy = (ignore