@@ -107,8 +107,12 @@ static void parse_line(char *line, MountData *output) {
107
107
if (output -> mountid < 0 ||
108
108
output -> fsname == NULL ||
109
109
output -> dir == NULL ||
110
- output -> fstype == NULL )
111
- goto errexit ;
110
+ output -> fstype == NULL ) {
111
+ fprintf (stderr , "Error: invalid MountData from line: '%s': mountid=%d fsname=%s dir=%s fstype=%s\n" ,
112
+ line , output -> mountid , output -> fsname , output -> dir ,
113
+ output -> fstype );
114
+ exit (1 );
115
+ }
112
116
113
117
// restore empty spaces
114
118
unmangle_path (output -> fsname );
@@ -117,7 +121,7 @@ static void parse_line(char *line, MountData *output) {
117
121
return ;
118
122
119
123
errexit :
120
- fprintf (stderr , "Error: cannot read /proc/self/mountinfo\n" );
124
+ fprintf (stderr , "Error: cannot parse line from /proc/self/mountinfo: '%s' \n" , line );
121
125
exit (1 );
122
126
}
123
127
@@ -127,7 +131,7 @@ MountData *get_last_mount(void) {
127
131
FILE * fp = fopen ("/proc/self/mountinfo" , "re" );
128
132
if (!fp ) {
129
133
fprintf (stderr , "Error: cannot read /proc/self/mountinfo\n" );
130
- exit ( 1 );
134
+ errExit ( "fopen" );
131
135
}
132
136
133
137
mbuf [0 ] = '\0' ;
@@ -158,8 +162,8 @@ static int get_mount_id_from_handle(int fd) {
158
162
int rv = -1 ;
159
163
int tmp ;
160
164
if (name_to_handle_at (-1 , proc , fh , & tmp , AT_SYMLINK_FOLLOW ) != -1 ) {
161
- fprintf (stderr , "Error: unexpected result from name_to_handle_at\n" );
162
- exit ( 1 );
165
+ fprintf (stderr , "Error: unexpected result from name_to_handle_at for fd %d \n" , fd );
166
+ errExit ( "name_to_handle_at" );
163
167
}
164
168
if (errno == EOVERFLOW && fh -> handle_bytes )
165
169
rv = tmp ;
@@ -184,8 +188,8 @@ static int get_mount_id_from_fdinfo(int fd) {
184
188
185
189
FILE * fp = fopen (proc , "re" );
186
190
if (!fp ) {
187
- fprintf (stderr , "Error: cannot read proc file \n" );
188
- exit ( 1 );
191
+ fprintf (stderr , "Error: cannot read %s \n" , proc );
192
+ errExit ( "fopen" );
189
193
}
190
194
191
195
if (called_as_root == 0 )
@@ -218,7 +222,7 @@ char **build_mount_array(const int mountid, const char *path) {
218
222
FILE * fp = fopen ("/proc/self/mountinfo" , "re" );
219
223
if (!fp ) {
220
224
fprintf (stderr , "Error: cannot read /proc/self/mountinfo\n" );
221
- exit ( 1 );
225
+ errExit ( "fopen" );
222
226
}
223
227
224
228
// try to find line with mount id
0 commit comments