Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print string error instead of integer errno #52

Closed
planetrocky opened this issue Jun 27, 2024 · 6 comments · Fixed by #54
Closed

print string error instead of integer errno #52

planetrocky opened this issue Jun 27, 2024 · 6 comments · Fixed by #54

Comments

@planetrocky
Copy link

Debugging on my system and had pages of fileio error.
Added simple stderror(errno) to symplify.

@planetrocky
Copy link
Author

planetrocky commented Jun 27, 2024

It’s not letting me create a branch; this is the diff:

admin@FS2 inotify-info $ git diff
         memset(&statxbuf, 0, sizeof(statxbuf));
     }
 
@@ -418,7 +418,7 @@ static dev_t stat_get_dev_t(const char* filename)
 
     int ret = stat(filename, &statbuf);
     if (ret == -1) {
-        printf("ERROR: stat-dev_t( %s ) failed. Errno: %d\n", filename, errno);
+        printf("ERROR: stat-dev_t( %s ) failed. Errno: %d (%s)\n", filename, errno, strerror(errno));
         return 0;
     }
     return statbuf.st_dev;
@@ -430,7 +430,7 @@ static uint64_t stat_get_ino(const char* filename)
 
     int ret = stat(filename, &statbuf);
     if (ret == -1) {
-        printf("ERROR: stat-ino( %s ) failed. Errno: %d\n", filename, errno);
+        printf("ERROR: stat-ino( %s ) failed. Errno: %d (%s)\n", filename, errno, strerror(errno));
         return 0;
     }
 
@@ -543,7 +543,7 @@ int thread_info_t::parse_dirqueue_entry()
             }
 
             if (spew_error) {
-                printf("ERROR: sys_getdents64 failed on '%s': %d errno:%d\n", path, ret, errno);
+                printf("ERROR: sys_getdents64 failed on '%s': %d errno:%d (%s)\n", path, ret, errno, strerror(errno));
             }
             break;
         }
@@ -829,7 +829,7 @@ static uint32_t find_files_in_inode_set(const std::vector<procinfo_t>& inotify_p
             thread_info.queue_directory(strdup("/"));
             thread_info.parse_dirqueue_entry();
         } else if (pthread_create(&thread_info.pthread_id, NULL,
 &parse_dirqueue_threadproc, &thread_info)) {
-            printf("Warning: pthread_create failed. errno: %d\n", errno);
+            printf("Warning: pthread_create failed. errno: %d (%s)\n", errno, strerror(errno));
             thread_info.pthread_id = 0;
         }
     }

@motiejus
Copy link
Collaborator

Lgtm,

@mikesart, thoughts?

@mikesart
Copy link
Owner

I'm fine with this getting committed. You want to do it @motiejus? For this:

Debugging on my system and had pages of fileio error

Would love to see what the errors you were getting are, and maybe run something like lsblk to see what your filesystem looks like? Thanks.

@planetrocky
Copy link
Author

I'm fine with this getting committed. You want to do it @motiejus? For this:

Debugging on my system and had pages of fileio error

Would love to see what the errors you were getting are, and maybe run something like lsblk to see what your filesystem looks like? Thanks.

See my next issue for the answer :)

I had random ERRNO 22 being returned :(

@planetrocky
Copy link
Author

I had to run lsblk in a container, as the host (Synology) doesn't have that command. This is one of the smaller systems:

NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
sda           8:0    0   9.1T  0 disk
|-sda1        8:1    0   2.4G  0 part
| `-md0       9:0    0   2.4G  0 raid1
|-sda2        8:2    0     2G  0 part
| `-md1       9:1    0     2G  0 raid1 [SWAP]
`-sda3        8:3    0   9.1T  0 part
  `-md2       9:2    0  54.5T  0 raid6
sdb           8:16   0   9.1T  0 disk
|-sdb1        8:17   0   2.4G  0 part
| `-md0       9:0    0   2.4G  0 raid1
|-sdb2        8:18   0     2G  0 part
| `-md1       9:1    0     2G  0 raid1 [SWAP]
`-sdb3        8:19   0   9.1T  0 part
  `-md2       9:2    0  54.5T  0 raid6
sdc           8:32   1   9.1T  0 disk
|-sdc1        8:33   1   2.4G  0 part
| `-md0       9:0    0   2.4G  0 raid1
|-sdc2        8:34   1     2G  0 part
| `-md1       9:1    0     2G  0 raid1 [SWAP]
`-sdc3        8:35   1   9.1T  0 part
  `-md2       9:2    0  54.5T  0 raid6
sdd           8:48   1   9.1T  0 disk
|-sdd1        8:49   1   2.4G  0 part
| `-md0       9:0    0   2.4G  0 raid1
|-sdd2        8:50   1     2G  0 part
| `-md1       9:1    0     2G  0 raid1 [SWAP]
`-sdd3        8:51   1   9.1T  0 part
  `-md2       9:2    0  54.5T  0 raid6
sde           8:64   1   9.1T  0 disk
|-sde1        8:65   1   2.4G  0 part
| `-md0       9:0    0   2.4G  0 raid1
|-sde2        8:66   1     2G  0 part
| `-md1       9:1    0     2G  0 raid1 [SWAP]
`-sde3        8:67   1   9.1T  0 part
  `-md2       9:2    0  54.5T  0 raid6
sdf           8:80   1   9.1T  0 disk
|-sdf1        8:81   1   2.4G  0 part
| `-md0       9:0    0   2.4G  0 raid1
|-sdf2        8:82   1     2G  0 part
| `-md1       9:1    0     2G  0 raid1 [SWAP]
`-sdf3        8:83   1   9.1T  0 part
  `-md2       9:2    0  54.5T  0 raid6
sdg           8:96   1   9.1T  0 disk
|-sdg1        8:97   1   2.4G  0 part
| `-md0       9:0    0   2.4G  0 raid1
|-sdg2        8:98   1     2G  0 part
| `-md1       9:1    0     2G  0 raid1 [SWAP]
`-sdg3        8:99   1   9.1T  0 part
  `-md2       9:2    0  54.5T  0 raid6
sdh           8:112  1   9.1T  0 disk
|-sdh1        8:113  1   2.4G  0 part
| `-md0       9:0    0   2.4G  0 raid1
|-sdh2        8:114  1     2G  0 part
| `-md1       9:1    0     2G  0 raid1 [SWAP]
`-sdh3        8:115  1   9.1T  0 part
  `-md2       9:2    0  54.5T  0 raid6
sdu          65:64   1  14.7G  0 disk
`-sdu1       65:65   1  14.7G  0 part
sdia        134:160  1  18.2T  0 disk
|-sdia1     134:161  1     8G  0 part
|-sdia2     134:162  1     2G  0 part
|-sdia5     134:165  1   1.8T  0 part
| `-md4       9:4    0   3.6T  0 raid5
|-sdia6     134:166  1   1.8T  0 part
| `-md5       9:5    0   3.6T  0 raid5
`-sdia7     134:167  1  14.6T  0 part
  `-md7       9:7    0  29.1T  0 raid5
sdib        134:176  1  18.2T  0 disk
|-sdib1     134:177  1     8G  0 part
|-sdib2     134:178  1     2G  0 part
|-sdib5     134:181  1   1.8T  0 part
| `-md4       9:4    0   3.6T  0 raid5
|-sdib6     134:182  1   1.8T  0 part
| `-md5       9:5    0   3.6T  0 raid5
`-sdib7     134:183  1  14.6T  0 part
  `-md7       9:7    0  29.1T  0 raid5
sdic        134:192  1  18.2T  0 disk
|-sdic1     134:193  1     8G  0 part
|-sdic2     134:194  1     2G  0 part
|-sdic5     134:197  1   1.8T  0 part
| `-md4       9:4    0   3.6T  0 raid5
|-sdic6     134:198  1   1.8T  0 part
| `-md5       9:5    0   3.6T  0 raid5
`-sdic7     134:199  1  14.6T  0 part
  `-md7       9:7    0  29.1T  0 raid5
sdie        134:224  1 931.5G  0 disk
`-sdie1     134:225  1 931.5G  0 part
  `-md3       9:3    0 931.5G  0 raid1
synoboot    135:240  0   120M  0 disk
|-synoboot1 135:241  0    16M  0 part
`-synoboot2 135:242  0   100M  0 part
zram0       248:0    0   4.7G  0 disk  [SWAP]
zram1       248:1    0   4.7G  0 disk  [SWAP]
zram2       248:2    0   4.7G  0 disk  [SWAP]
zram3       248:3    0   4.7G  0 disk  [SWAP]

motiejus added a commit to motiejus/inotify-info that referenced this issue Jun 28, 2024
@motiejus
Copy link
Collaborator

#54

motiejus added a commit to motiejus/inotify-info that referenced this issue Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants