| 1 | // Copyright (C) Microsoft Corporation. All rights reserved. |
| 2 | #pragma once |
| 3 | |
| 4 | #define MOUNT_INFO_FILE_NAME "/mountinfo" |
| 5 | #define MOUNT_INFO_FILE "/proc/self" MOUNT_INFO_FILE_NAME |
| 6 | |
| 7 | // Represents the parsed data from a line in the /proc/self/mountinfo file. |
| 8 | typedef struct _MOUNT_ENTRY |
| 9 | { |
| 10 | int Id; |
| 11 | int ParentId; |
| 12 | dev_t Device; |
| 13 | char* Root; |
| 14 | char* MountPoint; |
| 15 | char* MountOptions; |
| 16 | char* FileSystemType; |
| 17 | char* Source; |
| 18 | char* SuperOptions; |
| 19 | } MOUNT_ENTRY, *PMOUNT_ENTRY; |
| 20 | |
| 21 | // Represents an enumeration of entries in the /proc/self/mountinfo file. |
| 22 | typedef struct _MOUNT_ENUM |
| 23 | { |
| 24 | FILE* MountInfo; |
| 25 | char* Line; |
| 26 | size_t LineLength; |
| 27 | MOUNT_ENTRY Current; |
| 28 | } MOUNT_ENUM, *PMOUNT_ENUM; |
| 29 | |
| 30 | int MountEnumCreate(PMOUNT_ENUM mountEnum); |
| 31 | |
| 32 | int MountEnumCreateEx(PMOUNT_ENUM mountEnum, const char* mountInfoFile); |
| 33 | |
| 34 | void MountEnumFree(PMOUNT_ENUM mountEnum); |
| 35 | |
| 36 | int MountEnumNext(PMOUNT_ENUM mountEnum); |
| 37 | |
| 38 | int MountParseMountInfoLine(char* line, PMOUNT_ENTRY entry); |