Changeset View
Changeset View
Standalone View
Standalone View
src/solid/devices/backends/fstab/fstabhandling.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
72 | # endif | 72 | # endif | ||
73 | # endif | 73 | # endif | ||
74 | # endif | 74 | # endif | ||
75 | #endif | 75 | #endif | ||
76 | 76 | | |||
77 | // There are (at least) four kind of APIs: | 77 | // There are (at least) four kind of APIs: | ||
78 | // setmntent + getmntent + struct mntent (linux...) | 78 | // setmntent + getmntent + struct mntent (linux...) | ||
79 | // getmntent + struct mnttab | 79 | // getmntent + struct mnttab | ||
80 | // mntctl + struct vmount (AIX) | | |||
81 | // getmntinfo + struct statfs&flags (BSD 4.4 and friends) | 80 | // getmntinfo + struct statfs&flags (BSD 4.4 and friends) | ||
82 | // getfsent + char* (BSD 4.3 and friends) | 81 | // getfsent + char* (BSD 4.3 and friends) | ||
83 | 82 | | |||
84 | #if HAVE_SETMNTENT | 83 | #if HAVE_SETMNTENT | ||
85 | #define SETMNTENT setmntent | 84 | #define SETMNTENT setmntent | ||
86 | #define ENDMNTENT endmntent | 85 | #define ENDMNTENT endmntent | ||
87 | #define STRUCT_MNTENT struct mntent * | 86 | #define STRUCT_MNTENT struct mntent * | ||
88 | #define STRUCT_SETMNTENT FILE * | 87 | #define STRUCT_SETMNTENT FILE * | ||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Line(s) | 273 | for (int i = 0; i < num_fs; i++) { | |||
275 | QString type = QFile::decodeName(mounted[i].f_fstypename); | 274 | QString type = QFile::decodeName(mounted[i].f_fstypename); | ||
276 | if (_k_isFstabNetworkFileSystem(type, QString())) { | 275 | if (_k_isFstabNetworkFileSystem(type, QString())) { | ||
277 | const QString device = QFile::decodeName(mounted[i].f_mntfromname); | 276 | const QString device = QFile::decodeName(mounted[i].f_mntfromname); | ||
278 | const QString mountpoint = QFile::decodeName(mounted[i].f_mntonname); | 277 | const QString mountpoint = QFile::decodeName(mounted[i].f_mntonname); | ||
279 | globalFstabCache->m_mtabCache.insert(device, mountpoint); | 278 | globalFstabCache->m_mtabCache.insert(device, mountpoint); | ||
280 | } | 279 | } | ||
281 | } | 280 | } | ||
282 | 281 | | |||
283 | #elif defined(_AIX) | | |||
284 | | ||||
285 | struct vmount *mntctl_buffer; | | |||
286 | struct vmount *vm; | | |||
287 | char *mountedfrom; | | |||
288 | char *mountedto; | | |||
289 | int fsname_len, num; | | |||
290 | int buf_sz = 4096; | | |||
291 | | ||||
292 | mntctl_buffer = (struct vmount *)malloc(buf_sz); | | |||
293 | num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer); | | |||
294 | if (num == 0) { | | |||
295 | buf_sz = *(int *)mntctl_buffer; | | |||
296 | free(mntctl_buffer); | | |||
297 | mntctl_buffer = (struct vmount *)malloc(buf_sz); | | |||
298 | num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer); | | |||
299 | } | | |||
300 | | ||||
301 | if (num > 0) { | | |||
302 | /* iterate through items in the vmount structure: */ | | |||
303 | vm = (struct vmount *)mntctl_buffer; | | |||
304 | for (; num > 0; --num) { | | |||
305 | /* get the name of the mounted file systems: */ | | |||
306 | fsname_len = vmt2datasize(vm, VMT_STUB); | | |||
307 | mountedto = (char *)malloc(fsname_len + 1); | | |||
308 | mountedto[fsname_len] = '\0'; | | |||
309 | strncpy(mountedto, (char *)vmt2dataptr(vm, VMT_STUB), fsname_len); | | |||
310 | | ||||
311 | fsname_len = vmt2datasize(vm, VMT_OBJECT); | | |||
312 | mountedfrom = (char *)malloc(fsname_len + 1); | | |||
313 | mountedfrom[fsname_len] = '\0'; | | |||
314 | strncpy(mountedfrom, (char *)vmt2dataptr(vm, VMT_OBJECT), fsname_len); | | |||
315 | | ||||
316 | /* Look up the string for the file system type, | | |||
317 | * as listed in /etc/vfs. | | |||
318 | * ex.: nfs,jfs,afs,cdrfs,sfs,cachefs,nfs3,autofs | | |||
319 | */ | | |||
320 | struct vfs_ent *ent = getvfsbytype(vm->vmt_gfstype); | | |||
321 | | ||||
322 | QString type = QFile::decodeName(ent->vfsent_name); | | |||
323 | if (_k_isFstabNetworkFileSystem(type, QString())) { | | |||
324 | const QString device = QFile::decodeName(mountedfrom); | | |||
325 | const QString mountpoint = QFile::decodeName(mountedto); | | |||
326 | globalFstabCache->m_mtabCache.insert(device, mountpoint); | | |||
327 | } | | |||
328 | | ||||
329 | free(mountedfrom); | | |||
330 | free(mountedto); | | |||
331 | | ||||
332 | /* goto the next vmount structure: */ | | |||
333 | vm = (struct vmount *)((char *)vm + vm->vmt_length); | | |||
334 | } | | |||
335 | | ||||
336 | endvfsent(); | | |||
337 | } | | |||
338 | | ||||
339 | free(mntctl_buffer); | | |||
340 | #else | 282 | #else | ||
341 | STRUCT_SETMNTENT mnttab; | 283 | STRUCT_SETMNTENT mnttab; | ||
342 | if ((mnttab = SETMNTENT(MNTTAB, "r")) == nullptr) { | 284 | if ((mnttab = SETMNTENT(MNTTAB, "r")) == nullptr) { | ||
343 | return; | 285 | return; | ||
344 | } | 286 | } | ||
345 | 287 | | |||
346 | STRUCT_MNTENT fe; | 288 | STRUCT_MNTENT fe; | ||
347 | while (GETMNTENT(mnttab, fe)) { | 289 | while (GETMNTENT(mnttab, fe)) { | ||
Show All 28 Lines |