31
31
#include <stdio.h>
32
32
#include <string.h>
33
33
#include <mntent.h>
34
+ #include <sys/errno.h>
34
35
#include <sys/mnttab.h>
35
36
36
37
#include <sys/types.h>
@@ -82,7 +83,7 @@ _sol_getmntent(FILE *fp, struct mnttab *mgetp)
82
83
}
83
84
84
85
static int
85
- _linux_getextmntent (FILE * fp , struct extmnttab * mp , int len )
86
+ linux_getextmntent (FILE * fp , struct extmnttab * mp , int len )
86
87
{
87
88
int ret ;
88
89
struct stat64 st ;
@@ -104,10 +105,11 @@ _linux_getextmntent(FILE *fp, struct extmnttab *mp, int len)
104
105
int
105
106
getextmntent (const char * path , struct extmnttab * entry , struct stat64 * statbuf )
106
107
{
107
- int ret ;
108
108
struct stat64 st ;
109
+ FILE * fp ;
110
+ int match ;
109
111
110
- if (strlen (fullpath ) >= MAXPATHLEN ) {
112
+ if (strlen (path ) >= MAXPATHLEN ) {
111
113
(void ) fprintf (stderr , "invalid object; pathname too long\n" );
112
114
return (-1 );
113
115
}
@@ -118,9 +120,9 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
118
120
* or "//"), we stat() the path and search for the corresponding
119
121
* (major,minor) device pair.
120
122
*/
121
- if (stat64 (fullpath , statbuf ) != 0 ) {
123
+ if (stat64 (path , statbuf ) != 0 ) {
122
124
(void ) fprintf (stderr , "cannot open '%s': %s\n" ,
123
- fullpath , strerror (errno ));
125
+ path , strerror (errno ));
124
126
return (-1 );
125
127
}
126
128
@@ -139,22 +141,22 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
139
141
*/
140
142
141
143
match = 0 ;
142
- while (linux_getextmntent (fp , & mp , sizeof (mp )) == 0 ) {
143
- if (makedev (mp . mnt_major , mp . mnt_minor ) == statbuf -> st_dev ) {
144
+ while (linux_getextmntent (fp , entry , sizeof (* entry )) == 0 ) {
145
+ if (makedev (entry -> mnt_major , entry -> mnt_minor ) == statbuf -> st_dev ) {
144
146
match = 1 ;
145
147
break ;
146
148
}
147
149
}
148
150
149
151
if (!match ) {
150
152
(void ) fprintf (stderr , "cannot find mountpoint for '%s'\n" ,
151
- fullpath );
153
+ path );
152
154
return (-1 );
153
155
}
154
156
155
- if (stat64 (mp -> mnt_mountp , & st ) != 0 ) {
156
- mp -> mnt_major = 0 ;
157
- mp -> mnt_minor = 0 ;
157
+ if (stat64 (entry -> mnt_mountp , & st ) != 0 ) {
158
+ entry -> mnt_major = 0 ;
159
+ entry -> mnt_minor = 0 ;
158
160
return (-1 );
159
161
}
160
162
0 commit comments