]> arthur.barton.de Git - netdata.git/blobdiff - src/proc_self_mountinfo.c
Separate net.inet.ip.stats module
[netdata.git] / src / proc_self_mountinfo.c
index 49755217e2b7ab7406db785723dad7ea9cb8e3a0..bb031a9ab40e808b0c8f26082806ac48cd5e6b9c 100644 (file)
@@ -7,39 +7,39 @@
 /* A file system is "remote" if its Fs_name contains a ':'
    or if (it is of type (smbfs or cifs) and its Fs_name starts with '//')
    or Fs_name is equal to "-hosts" (used by autofs to mount remote fs).  */
-# define ME_REMOTE(Fs_name, Fs_type)             \
-    (strchr (Fs_name, ':') != NULL               \
-     || ((Fs_name)[0] == '/'                     \
-         && (Fs_name)[1] == '/'                  \
-         && (strsame (Fs_type, "smbfs") == 0     \
-             || strsame (Fs_type, "cifs") == 0)) \
-     || (strsame("-hosts", Fs_name) == 0))
+# define ME_REMOTE(Fs_name, Fs_type)            \
+    (strchr (Fs_name, ':') != NULL              \
+     || ((Fs_name)[0] == '/'                    \
+         && (Fs_name)[1] == '/'                 \
+         && (strcmp (Fs_type, "smbfs") == 0     \
+             || strcmp (Fs_type, "cifs") == 0)) \
+     || (strcmp("-hosts", Fs_name) == 0))
 #endif
 
-#define ME_DUMMY_0(Fs_name, Fs_type)             \
-  (strsame (Fs_type, "autofs") == 0              \
-   || strsame (Fs_type, "proc") == 0             \
-   || strsame (Fs_type, "subfs") == 0            \
-   /* for Linux 2.6/3.x */                       \
-   || strsame (Fs_type, "debugfs") == 0          \
-   || strsame (Fs_type, "devpts") == 0           \
-   || strsame (Fs_type, "fusectl") == 0          \
-   || strsame (Fs_type, "mqueue") == 0           \
-   || strsame (Fs_type, "rpc_pipefs") == 0       \
-   || strsame (Fs_type, "sysfs") == 0            \
-   /* FreeBSD, Linux 2.4 */                      \
-   || strsame (Fs_type, "devfs") == 0            \
-   /* for NetBSD 3.0 */                          \
-   || strsame (Fs_type, "kernfs") == 0           \
-   /* for Irix 6.5 */                            \
-   || strsame (Fs_type, "ignore") == 0)
+#define ME_DUMMY_0(Fs_name, Fs_type)            \
+  (strcmp (Fs_type, "autofs") == 0              \
+   || strcmp (Fs_type, "proc") == 0             \
+   || strcmp (Fs_type, "subfs") == 0            \
+   /* for Linux 2.6/3.x */                      \
+   || strcmp (Fs_type, "debugfs") == 0          \
+   || strcmp (Fs_type, "devpts") == 0           \
+   || strcmp (Fs_type, "fusectl") == 0          \
+   || strcmp (Fs_type, "mqueue") == 0           \
+   || strcmp (Fs_type, "rpc_pipefs") == 0       \
+   || strcmp (Fs_type, "sysfs") == 0            \
+   /* FreeBSD, Linux 2.4 */                     \
+   || strcmp (Fs_type, "devfs") == 0            \
+   /* for NetBSD 3.0 */                         \
+   || strcmp (Fs_type, "kernfs") == 0           \
+   /* for Irix 6.5 */                           \
+   || strcmp (Fs_type, "ignore") == 0)
 
 /* Historically, we have marked as "dummy" any file system of type "none",
    but now that programs like du need to know about bind-mounted directories,
    we grant an exception to any with "bind" in its list of mount options.
    I.e., those are *not* dummy entries.  */
 # define ME_DUMMY(Fs_name, Fs_type)            \
-  (ME_DUMMY_0 (Fs_name, Fs_type) || strsame (Fs_type, "none") == 0)
+  (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)
 
 // ----------------------------------------------------------------------------
 
@@ -66,8 +66,8 @@ struct mountinfo *mountinfo_find_by_filesystem_mount_source(struct mountinfo *ro
                 && mi->mount_source
                 && mi->filesystem_hash == filesystem_hash
                 && mi->mount_source_hash == mount_source_hash
-                && !strsame(mi->filesystem, filesystem)
-                && !strsame(mi->mount_source, mount_source)))
+                && !strcmp(mi->filesystem, filesystem)
+                && !strcmp(mi->mount_source, mount_source)))
             return mi;
 
     return NULL;
@@ -83,7 +83,7 @@ struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *ro
         if(unlikely(mi->filesystem
                 && mi->super_options
                 && mi->filesystem_hash == filesystem_hash
-                && !strsame(mi->filesystem, filesystem))) {
+                && !strcmp(mi->filesystem, filesystem))) {
 
             // super_options is a comma separated list
             char *s = mi->super_options, *e;
@@ -163,7 +163,7 @@ static inline int is_read_only(const char *s) {
     size_t len = strlen(s);
     if(len < 2) return 0;
     if(len == 2) {
-        if(!strsame(s, "ro")) return 1;
+        if(!strcmp(s, "ro")) return 1;
         return 0;
     }
     if(!strncmp(s, "ro,", 3)) return 1;
@@ -175,10 +175,10 @@ static inline int is_read_only(const char *s) {
 // read the whole mountinfo into a linked list
 struct mountinfo *mountinfo_read(int do_statvfs) {
     char filename[FILENAME_MAX + 1];
-    snprintfz(filename, FILENAME_MAX, "%s/proc/self/mountinfo", global_host_prefix);
+    snprintfz(filename, FILENAME_MAX, "%s/proc/self/mountinfo", netdata_configured_host_prefix);
     procfile *ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
     if(unlikely(!ff)) {
-        snprintfz(filename, FILENAME_MAX, "%s/proc/1/mountinfo", global_host_prefix);
+        snprintfz(filename, FILENAME_MAX, "%s/proc/1/mountinfo", netdata_configured_host_prefix);
         ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
         if(unlikely(!ff)) return NULL;
     }
@@ -293,7 +293,7 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
 
                     struct mountinfo *mt;
                     for(mt = root; mt; mt = mt->next) {
-                        if(unlikely(mt->st_dev == mi->st_dev && !(mi->flags & MOUNTINFO_NO_STAT))) {
+                        if(unlikely(mt->st_dev == mi->st_dev && !(mt->flags & MOUNTINFO_IS_SAME_DEV))) {
                             if(strlen(mi->mount_point) < strlen(mt->mount_point))
                                 mt->flags |= MOUNTINFO_IS_SAME_DEV;
                             else
@@ -319,7 +319,7 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
         }
 
         // check if it has size
-        if(do_statvfs) {
+        if(do_statvfs && !(mi->flags & MOUNTINFO_IS_DUMMY)) {
             struct statvfs buff_statvfs;
             if(unlikely(statvfs(mi->mount_point, &buff_statvfs) < 0)) {
                 mi->flags |= MOUNTINFO_NO_STAT;
@@ -376,7 +376,7 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
                 if(unlikely(bind)) {
                     struct mountinfo *mi;
                     for(mi = root; mi ; mi = mi->next) {
-                        if(unlikely(strsame(mnt->mnt_dir, mi->mount_point) == 0)) {
+                        if(unlikely(strcmp(mnt->mnt_dir, mi->mount_point) == 0)) {
                             fprintf(stderr, "Mount point '%s' is BIND\n", mi->mount_point);
                             mi->flags |= MOUNTINFO_IS_BIND;
                             break;