]> arthur.barton.de Git - netdata.git/blobdiff - src/proc_self_mountinfo.c
Merge pull request #1923 from ktsaou/master
[netdata.git] / src / proc_self_mountinfo.c
index 8471d407bd4e01c533cfdd957daeaf932afa6040..bb031a9ab40e808b0c8f26082806ac48cd5e6b9c 100644 (file)
@@ -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;
     }
@@ -197,8 +197,8 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
         mi = mallocz(sizeof(struct mountinfo));
 
         unsigned long w = 0;
-        mi->id = strtoul(procfile_lineword(ff, l, w), NULL, 10); w++;
-        mi->parentid = strtoul(procfile_lineword(ff, l, w), NULL, 10); w++;
+        mi->id = str2ul(procfile_lineword(ff, l, w)); w++;
+        mi->parentid = str2ul(procfile_lineword(ff, l, w)); w++;
 
         char *major = procfile_lineword(ff, l, w), *minor; w++;
         for(minor = major; *minor && *minor != ':' ;minor++) ;
@@ -214,8 +214,8 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
 
         mi->flags = 0;
 
-        mi->major = strtoul(major, NULL, 10);
-        mi->minor = strtoul(minor, NULL, 10);
+        mi->major = str2ul(major);
+        mi->minor = str2ul(minor);
 
         mi->root = strdupz(procfile_lineword(ff, l, w)); w++;
         mi->root_hash = simple_hash(mi->root);
@@ -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;