Code

src/urils_mount.c: Use `getvfsstat' on NetBSD, if available.
[collectd.git] / src / utils_mount.c
1 /**
2  * collectd - src/utils_mount.c
3  * Copyright (C) 2005,2006  Niki W. Waibel
4  *
5  * This program is free software; you can redistribute it and/
6  * or modify it under the terms of the GNU General Public Li-
7  * cence as published by the Free Software Foundation; either
8  * version 2 of the Licence, or any later version.
9  *
10  * This program is distributed in the hope that it will be use-
11  * ful, but WITHOUT ANY WARRANTY; without even the implied war-
12  * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public Licence for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * Licence along with this program; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
18  * USA.
19  *
20  * Author:
21  *   Niki W. Waibel <niki.waibel@gmx.net>
22 **/
26 #include "common.h"
27 #if HAVE_XFS_XQM_H
28 # include <xfs/xqm.h>
29 #define XFS_SUPER_MAGIC_STR "XFSB"
30 #define XFS_SUPER_MAGIC2_STR "BSFX"
31 #endif
33 #include "utils_debug.h"
34 #include "utils_mount.h"
36 #if HAVE_GETFSSTAT
37 #  if HAVE_SYS_PARAM_H
38 #    include <sys/param.h>
39 #  endif
40 #  if HAVE_SYS_UCRED_H
41 #    include <sys/ucred.h>
42 #  endif
43 #  if HAVE_SYS_MOUNT_H
44 #    include <sys/mount.h>
45 #  endif
46 /* #endif HAVE_GETFSSTAT */
47 #elif HAVE_GETVFSSTAT
48 #  if HAVE_SYS_TYPES_H
49 #    include <sys/types.h>
50 #  endif
51 #  if HAVE_SYS_STATVFS_H
52 #    include <sys/statvfs.h>
53 #  endif
54 #endif /* HAVE_GETVFSSTAT */
56 #if HAVE_MNTENT_H
57 #  include <mntent.h>
58 #endif
59 #if HAVE_SYS_MNTTAB_H
60 #  include <sys/mnttab.h>
61 #endif
63 #if HAVE_PATHS_H
64 #  include <paths.h>
65 #endif
67 #ifdef COLLECTD_MNTTAB
68 #  undef COLLECTD_MNTTAB
69 #endif
71 #if defined(_PATH_MOUNTED) /* glibc */
72 #  define COLLECTD_MNTTAB _PATH_MOUNTED
73 #elif defined(MNTTAB) /* Solaris */
74 #  define COLLECTD_MNTTAB MNTTAB
75 #elif defined(MNT_MNTTAB)
76 #  define COLLECTD_MNTTAB MNT_MNTTAB
77 #elif defined(MNTTABNAME)
78 #  define COLLECTD_MNTTAB MNTTABNAME
79 #elif defined(KMTAB)
80 #  define COLLECTD_MNTTAB KMTAB
81 #else
82 #  define COLLECTD_MNTTAB "/etc/mnttab"
83 #endif
85 /* *** *** *** ********************************************* *** *** *** */
86 /* *** *** *** *** *** ***   private functions   *** *** *** *** *** *** */
87 /* *** *** *** ********************************************* *** *** *** */
89 /* stolen from quota-3.13 (quota-tools) */
91 #define PROC_PARTITIONS "/proc/partitions"
92 #define DEVLABELDIR     "/dev"
93 #define UUID   1
94 #define VOL    2
96 static struct uuidCache_s {
97         struct uuidCache_s *next;
98         char uuid[16];
99         char *label;
100         char *device;
101 } *uuidCache = NULL;
103 #define EXT2_SUPER_MAGIC 0xEF53
104 struct ext2_super_block {
105         unsigned char s_dummy1[56];
106         unsigned char s_magic[2];
107         unsigned char s_dummy2[46];
108         unsigned char s_uuid[16];
109         char s_volume_name[16];
110 };
111 #define ext2magic(s) ((unsigned int)s.s_magic[0] \
112         + (((unsigned int)s.s_magic[1]) << 8))
114 #if HAVE_XFS_XQM_H
115 struct xfs_super_block {
116         unsigned char s_magic[4];
117         unsigned char s_dummy[28];
118         unsigned char s_uuid[16];
119         unsigned char s_dummy2[60];
120         char s_fsname[12];
121 };
122 #endif /* HAVE_XFS_XQM_H */
124 #define REISER_SUPER_MAGIC "ReIsEr2Fs"
125 struct reiserfs_super_block {
126         unsigned char s_dummy1[52];
127         unsigned char s_magic[10];
128         unsigned char s_dummy2[22];
129         unsigned char s_uuid[16];
130         char s_volume_name[16];
131 };
133 /* for now, only ext2 and xfs are supported */
134 static int
135 get_label_uuid(const char *device, char **label, char *uuid)
137         /* start with ext2 and xfs tests, taken from mount_guess_fstype */
138         /* should merge these later */
139         int fd, rv = 1;
140         size_t namesize;
141         struct ext2_super_block e2sb;
142 #if HAVE_XFS_XQM_H
143         struct xfs_super_block xfsb;
144 #endif
145         struct reiserfs_super_block reisersb;
147         fd = open(device, O_RDONLY);
148         if(fd == -1) {
149                 return rv;
150         }
152         if(lseek(fd, 1024, SEEK_SET) == 1024
153         && read(fd, (char *)&e2sb, sizeof(e2sb)) == sizeof(e2sb)
154         && ext2magic(e2sb) == EXT2_SUPER_MAGIC) {
155                 memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid));
156                 namesize = sizeof(e2sb.s_volume_name);
157                 *label = smalloc(namesize + 1);
158                 sstrncpy(*label, e2sb.s_volume_name, namesize);
159                 rv = 0;
160 #if HAVE_XFS_XQM_H
161         } else if(lseek(fd, 0, SEEK_SET) == 0
162         && read(fd, (char *)&xfsb, sizeof(xfsb)) == sizeof(xfsb)
163         && (strncmp((char *)&xfsb.s_magic, XFS_SUPER_MAGIC_STR, 4) == 0 ||
164         strncmp((char *)&xfsb.s_magic, XFS_SUPER_MAGIC2_STR, 4) == 0)) {
165                 memcpy(uuid, xfsb.s_uuid, sizeof(xfsb.s_uuid));
166                 namesize = sizeof(xfsb.s_fsname);
167                 *label = smalloc(namesize + 1);
168                 sstrncpy(*label, xfsb.s_fsname, namesize);
169                 rv = 0;
170 #endif /* HAVE_XFS_XQM_H */
171         } else if(lseek(fd, 65536, SEEK_SET) == 65536
172         && read(fd, (char *)&reisersb, sizeof(reisersb)) == sizeof(reisersb)
173         && !strncmp((char *)&reisersb.s_magic, REISER_SUPER_MAGIC, 9)) {
174                 memcpy(uuid, reisersb.s_uuid, sizeof(reisersb.s_uuid));
175                 namesize = sizeof(reisersb.s_volume_name);
176                 *label = smalloc(namesize + 1);
177                 sstrncpy(*label, reisersb.s_volume_name, namesize);
178                 rv = 0;
179         }
180         close(fd);
181         return rv;
184 static void
185 uuidcache_addentry(char *device, char *label, char *uuid)
187         struct uuidCache_s *last;
189         if(!uuidCache) {
190                 last = uuidCache = smalloc(sizeof(*uuidCache));
191         } else {
192                 for(last = uuidCache; last->next; last = last->next);
193                 last->next = smalloc(sizeof(*uuidCache));
194                 last = last->next;
195         }
196         last->next = NULL;
197         last->device = device;
198         last->label = label;
199         memcpy(last->uuid, uuid, sizeof(last->uuid));
202 static void
203 uuidcache_init(void)
205         char line[100];
206         char *s;
207         int ma, mi, sz;
208         static char ptname[100];
209         FILE *procpt;
210         char uuid[16], *label = NULL;
211         char device[110];
212         int firstPass;
213         int handleOnFirst;
215         if(uuidCache) {
216                 return;
217         }
219         procpt = fopen(PROC_PARTITIONS, "r");
220         if(procpt == NULL) {
221                 return;
222         }
224         for(firstPass = 1; firstPass >= 0; firstPass--) {
225                 fseek(procpt, 0, SEEK_SET);
226                 while(fgets(line, sizeof(line), procpt)) {
227                         if(sscanf(line, " %d %d %d %[^\n ]",
228                                 &ma, &mi, &sz, ptname) != 4)
229                         {
230                                 continue;
231                         }
233                         /* skip extended partitions (heuristic: size 1) */
234                         if(sz == 1) {
235                                 continue;
236                         }
238                         /* look only at md devices on first pass */
239                         handleOnFirst = !strncmp(ptname, "md", 2);
240                         if(firstPass != handleOnFirst) {
241                                 continue;
242                         }
244                         /* skip entire disk (minor 0, 64, ... on ide;
245                         0, 16, ... on sd) */
246                         /* heuristic: partition name ends in a digit */
248                         for(s = ptname; *s; s++);
250                         if(isdigit((int)s[-1])) {
251                         /*
252                         * Note: this is a heuristic only - there is no reason
253                         * why these devices should live in /dev.
254                         * Perhaps this directory should be specifiable by option.
255                         * One might for example have /devlabel with links to /dev
256                         * for the devices that may be accessed in this way.
257                         * (This is useful, if the cdrom on /dev/hdc must not
258                         * be accessed.)
259                         */
260                                 snprintf(device, sizeof(device), "%s/%s",
261                                         DEVLABELDIR, ptname);
262                                 if(!get_label_uuid(device, &label, uuid)) {
263                                         uuidcache_addentry(sstrdup(device),
264                                                 label, uuid);
265                                 }
266                         }
267                 }
268         }
269         fclose(procpt);
272 static unsigned char
273 fromhex(char c)
275         if(isdigit((int)c)) {
276                 return (c - '0');
277         } else if(islower((int)c)) {
278                 return (c - 'a' + 10);
279         } else {
280                 return (c - 'A' + 10);
281         }
284 static char *
285 get_spec_by_x(int n, const char *t)
287         struct uuidCache_s *uc;
289         uuidcache_init();
290         uc = uuidCache;
292         while(uc) {
293                 switch(n) {
294                 case UUID:
295                         if(!memcmp(t, uc->uuid, sizeof(uc->uuid))) {
296                                 return sstrdup(uc->device);
297                         }
298                         break;
299                 case VOL:
300                         if(!strcmp(t, uc->label)) {
301                                 return sstrdup(uc->device);
302                         }
303                         break;
304                 }
305                 uc = uc->next;
306         }
307         return NULL;
310 static char *
311 get_spec_by_uuid(const char *s)
313         char uuid[16];
314         int i;
316         if(strlen(s) != 36
317         || s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-') {
318                 goto bad_uuid;
319         }
321         for(i=0; i<16; i++) {
322                 if(*s == '-') {
323                         s++;
324                 }
325                 if(!isxdigit((int)s[0]) || !isxdigit((int)s[1])) {
326                         goto bad_uuid;
327                 }
328                 uuid[i] = ((fromhex(s[0]) << 4) | fromhex(s[1]));
329                 s += 2;
330         }
331         return get_spec_by_x(UUID, uuid);
333         bad_uuid:
334                 DBG("Found an invalid UUID: %s", s);
335         return NULL;
338 static char *get_spec_by_volume_label(const char *s)
340         return get_spec_by_x (VOL, s);
343 static char *get_device_name(const char *optstr)
345         char *rc;
347         if (optstr == NULL)
348         {
349                 return (NULL);
350         }
351         else if (strncmp (optstr, "UUID=", 5) == 0)
352         {
353                 DBG ("TODO: check UUID= code!");
354                 rc = get_spec_by_uuid (optstr + 5);
355         }
356         else if (strncmp (optstr, "LABEL=", 6) == 0)
357         {
358                 DBG ("TODO: check LABEL= code!");
359                 rc = get_spec_by_volume_label (optstr + 6);
360         }
361         else
362         {
363                 rc = sstrdup (optstr);
364         }
366         if(!rc)
367         {
368                 DBG ("Error checking device name: optstr = %s", optstr);
369         }
370         return rc;
373 /* What weird OS is this..? I can't find any info with google :/ -octo */
374 #if HAVE_LISTMNTENT && 0
375 static cu_mount_t *cu_mount_listmntent (void)
377         cu_mount_t *last = *list;
378         struct tabmntent *p;
379         struct mntent *mnt;
381         struct tabmntent *mntlist;
382         if(listmntent(&mntlist, COLLECTD_MNTTAB, NULL, NULL) < 0) {
383                 DBG("calling listmntent() failed: %s", strerror(errno));
384         }
386         for(p = mntlist; p; p = p->next) {
387                 char *loop = NULL, *device = NULL;
389                 mnt = p->ment;
390                 loop = cu_mount_getoptionvalue(mnt->mnt_opts, "loop=");
391                 if(loop == NULL) {   /* no loop= mount */
392                         device = get_device_name(mnt->mnt_fsname);
393                         if(device == NULL) {
394                                 DBG("can't get devicename for fs (%s) %s (%s)"
395                                         ": ignored", mnt->mnt_type,
396                                         mnt->mnt_dir, mnt->mnt_fsname);
397                                 continue;
398                         }
399                 } else {
400                         device = loop;
401                 }
402                 if(*list == NULL) {
403                         *list = (cu_mount_t *)smalloc(sizeof(cu_mount_t));
404                         last = *list;
405                 } else {
406                         while(last->next != NULL) { /* is last really last? */
407                                 last = last->next;
408                         }
409                         last->next = (cu_mount_t *)smalloc(sizeof(cu_mount_t));
410                         last = last->next;
411                 }
412                 last->dir = sstrdup(mnt->mnt_dir);
413                 last->spec_device = sstrdup(mnt->mnt_fsname);
414                 last->device = device;
415                 last->type = sstrdup(mnt->mnt_type);
416                 last->options = sstrdup(mnt->mnt_opts);
417                 last->next = NULL;
418         } /* for(p = mntlist; p; p = p->next) */
420         return(last);
421 } /* cu_mount_t *cu_mount_listmntent(void) */
422 /* #endif HAVE_LISTMNTENT */
424 /* 4.4BSD and Mac OS X (getfsstat) or NetBSD (getvfsstat) */
425 #elif HAVE_GETFSSTAT || HAVE_GETVFSSTAT
426 static cu_mount_t *cu_mount_getfsstat (void)
428 #if HAVE_GETFSSTAT
429 #  define STRUCT_STATFS struct statfs
430 #  define CMD_STATFS    getfsstat
431 #  define FLAGS_STATFS  MNT_NOWAIT
432 /* #endif HAVE_GETFSSTAT */
433 #elif HAVE_GETVFSSTAT
434 #  define STRUCT_STATFS struct statvfs
435 #  define CMD_STATFS    getvfsstat
436 #  define FLAGS_STATFS  ST_NOWAIT
437 #endif /* HAVE_GETVFSSTAT */
439         int bufsize;
440         STRUCT_STATFS *buf;
442         int num;
443         int i;
445         cu_mount_t *first = NULL;
446         cu_mount_t *last  = NULL;
447         cu_mount_t *new   = NULL;
449         /* Get the number of mounted file systems */
450         if ((bufsize = CMD_STATFS (NULL, 0, FLAGS_STATFS)) < 1)
451         {
452                 DBG (CMD_STATFS" failed: %s", strerror (errno));
453                 return (NULL);
454         }
456         if ((buf = (STRUCT_STATFS *) malloc (bufsize * sizeof (STRUCT_STATFS)))
457                         == NULL)
458                 return (NULL);
459         memset (buf, '\0', bufsize * sizeof (STRUCT_STATFS));
461         /* The bufsize needs to be passed in bytes. Really. This is not in the
462          * manpage.. -octo */
463         if ((num = CMD_STATFS (buf, bufsize * sizeof (STRUCT_STATFS), FLAGS_STATFS)) < 1)
464         {
465                 DBG (CMD_STATFS" failed: %s", strerror (errno));
466                 free (buf);
467                 return (NULL);
468         }
470         for (i = 0; i < num; i++)
471         {
472                 if ((new = malloc (sizeof (cu_mount_t))) == NULL)
473                         break;
474                 memset (new, '\0', sizeof (cu_mount_t));
475                 
476                 /* Copy values from `struct mnttab' */
477                 new->dir         = sstrdup (buf[i].f_mntonname);
478                 new->spec_device = sstrdup (buf[i].f_mntfromname);
479                 new->type        = sstrdup (buf[i].f_fstypename);
480                 new->options     = NULL;
481                 new->device      = get_device_name (new->options);
482                 new->next = NULL;
484                 /* Append to list */
485                 if (first == NULL)
486                 {
487                         first = new;
488                         last  = new;
489                 }
490                 else
491                 {
492                         last->next = new;
493                         last       = new;
494                 }
495         }
497         free (buf);
499         return (first);
501 /* #endif HAVE_GETFSSTAT */
503 /* Solaris (SunOS 10): int getmntent(FILE *fp, struct mnttab *mp); */
504 #elif HAVE_GEN_GETMNTENT
505 static cu_mount_t *cu_mount_gen_getmntent (void)
507         struct mnttab mt;
508         FILE *fp;
510         cu_mount_t *first = NULL;
511         cu_mount_t *last  = NULL;
512         cu_mount_t *new   = NULL;
514         DBG ("(void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
516         if ((fp = fopen (COLLECTD_MNTTAB, "r")) == NULL)
517         {
518                 syslog (LOG_ERR, "fopen (%s): %s", COLLECTD_MNTTAB, strerror (errno));
519                 return (NULL);
520         }
522         while (getmntent (fp, &mt) == 0)
523         {
524                 if ((new = malloc (sizeof (cu_mount_t))) == NULL)
525                         break;
526                 memset (new, '\0', sizeof (cu_mount_t));
527                 
528                 /* Copy values from `struct mnttab' */
529                 new->dir         = sstrdup (mt.mnt_mountp);
530                 new->spec_device = sstrdup (mt.mnt_special);
531                 new->type        = sstrdup (mt.mnt_fstype);
532                 new->options     = sstrdup (mt.mnt_mntopts);
533                 new->device      = get_device_name (new->options);
534                 new->next = NULL;
536                 /* Append to list */
537                 if (first == NULL)
538                 {
539                         first = new;
540                         last  = new;
541                 }
542                 else
543                 {
544                         last->next = new;
545                         last       = new;
546                 }
547         }
549         fclose (fp);
551         return (first);
552 } /* static cu_mount_t *cu_mount_gen_getmntent (void) */
553 /* #endif HAVE_GEN_GETMNTENT */
555 #elif HAVE_SEQ_GETMNTENT
556 #warn "This version of `getmntent' hat not yet been implemented!"
557 /* #endif HAVE_SEQ_GETMNTENT */
559 #elif HAVE_SUN_GETMNTENT
560 #warn "This version of `getmntent' hat not yet been implemented!"
561 /* #endif HAVE_SUN_GETMNTENT */
563 #elif HAVE_GETMNTENT
564 static cu_mount_t *cu_mount_getmntent (void)
566         FILE *fp;
567         struct mntent *me;
569         cu_mount_t *first = NULL;
570         cu_mount_t *last  = NULL;
571         cu_mount_t *new   = NULL;
573         DBG ("(void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
575         if ((fp = setmntent (COLLECTD_MNTTAB, "r")) == NULL)
576         {
577                 syslog (LOG_ERR, "setmntent (%s): %s", COLLECTD_MNTTAB, strerror (errno));
578                 return (NULL);
579         }
581         while ((me = getmntent (fp)) != NULL)
582         {
583                 if ((new = malloc (sizeof (cu_mount_t))) == NULL)
584                         break;
585                 memset (new, '\0', sizeof (cu_mount_t));
586                 
587                 /* Copy values from `struct mntent *' */
588                 new->dir         = sstrdup (me->mnt_dir);
589                 new->spec_device = sstrdup (me->mnt_fsname);
590                 new->type        = sstrdup (me->mnt_type);
591                 new->options     = sstrdup (me->mnt_opts);
592                 new->device      = get_device_name (new->options);
593                 new->next        = NULL;
595                 DBG ("new = {dir = %s, spec_device = %s, type = %s, options = %s, device = %s}",
596                                 new->dir, new->spec_device, new->type, new->options, new->device);
598                 /* Append to list */
599                 if (first == NULL)
600                 {
601                         first = new;
602                         last  = new;
603                 }
604                 else
605                 {
606                         last->next = new;
607                         last       = new;
608                 }
609         }
611         endmntent (fp);
613         DBG ("return (0x%p)", (void *) first);
615         return (first);
617 #endif /* HAVE_GETMNTENT */
619 /* *** *** *** ******************************************** *** *** *** */
620 /* *** *** *** *** *** ***   public functions   *** *** *** *** *** *** */
621 /* *** *** *** ******************************************** *** *** *** */
623 cu_mount_t *cu_mount_getlist(cu_mount_t **list)
625         cu_mount_t *new;
626         cu_mount_t *first = NULL;
627         cu_mount_t *last  = NULL;
629         if (list == NULL)
630                 return (NULL);
632         if (*list != NULL)
633         {
634                 first = *list;
635                 last  =  first;
636                 while (last->next != NULL)
637                         last = last->next;
638         }
640 #if HAVE_LISTMNTENT && 0
641         new = cu_mount_listmntent ();
642 #elif HAVE_GETFSSTAT
643         new = cu_mount_getfsstat ();
644 #elif HAVE_GEN_GETMNTENT
645         new = cu_mount_gen_getmntent ();
646 #elif HAVE_GETMNTENT
647         new = cu_mount_getmntent ();
648 #else
649         new = NULL;
650 #endif
652         if (first != NULL)
653         {
654                 last->next = new;
655         }
656         else
657         {
658                 first = new;
659                 last  = new;
660                 *list = first;
661         }
663         while ((last != NULL) && (last->next != NULL))
664                 last = last->next;
666         return (last);
667 } /* cu_mount_t *cu_mount_getlist(cu_mount_t **list) */
669 void cu_mount_freelist (cu_mount_t *list)
671         cu_mount_t *this;
672         cu_mount_t *next;
674         DBG ("(list = 0x%p)", (void *) list);
676         for (this = list; this != NULL; this = next)
677         {
678                 next = this->next;
680                 sfree (this->dir);
681                 sfree (this->spec_device);
682                 sfree (this->device);
683                 sfree (this->type);
684                 sfree (this->options);
685                 sfree (this);
686         }
687 } /* void cu_mount_freelist(cu_mount_t *list) */
689 char *
690 cu_mount_checkoption(char *line, char *keyword, int full)
692         char *line2, *l2;
693         int l = strlen(keyword);
694         char *p1, *p2;
696         if(line == NULL || keyword == NULL) {
697                 return NULL;
698         }
699         if(full != 0) {
700                 full = 1;
701         }
703         line2 = sstrdup(line);
704         l2 = line2;
705         while(*l2 != '\0') {
706                 if(*l2 == ',') {
707                         *l2 = '\0';
708                 }
709                 l2++;
710         }
712         p1 = line - 1;
713         p2 = strchr(line, ',');
714         do {
715                 if(strncmp(line2+(p1-line)+1, keyword, l+full) == 0) {
716                         free(line2);
717                         return p1+1;
718                 }
719                 p1 = p2;
720                 if(p1 != NULL) {
721                         p2 = strchr(p1+1, ',');
722                 }
723         } while(p1 != NULL);
725         free(line2);
726         return NULL;
727 } /* char *cu_mount_checkoption(char *line, char *keyword, int full) */
729 char *
730 cu_mount_getoptionvalue(char *line, char *keyword)
732         char *r;
734         r = cu_mount_checkoption(line, keyword, 0);
735         if(r != NULL) {
736                 char *p;
737                 r += strlen(keyword);
738                 p = strchr(r, ',');
739                 if(p == NULL) {
740                         if(strlen(r) == 0) {
741                                 return NULL;
742                         }
743                         return sstrdup(r);
744                 } else {
745                         char *m;
746                         if((p-r) == 1) {
747                                 return NULL;
748                         }
749                         m = (char *)smalloc(p-r+1);
750                         sstrncpy(m, r, p-r+1);
751                         return m;
752                 }
753         }
754         return r;
755 } /* char *cu_mount_getoptionvalue(char *line, char *keyword) */
759 int
760 cu_mount_type(const char *type)
762         if(strcmp(type, "ext3") == 0) return CUMT_EXT3;
763         if(strcmp(type, "ext2") == 0) return CUMT_EXT2;
764         if(strcmp(type, "ufs")  == 0) return CUMT_UFS;
765         if(strcmp(type, "vxfs") == 0) return CUMT_VXFS;
766         if(strcmp(type, "zfs")  == 0) return CUMT_ZFS;
767         return CUMT_UNKNOWN;
768 } /* int cu_mount_type(const char *type) */