diff options
Diffstat (limited to 'mtab.c')
-rw-r--r-- | mtab.c | 42 |
1 files changed, 0 insertions, 42 deletions
@@ -59,48 +59,6 @@ erase_mtab(const char * name) | |||
59 | perror(mtab_file); | 59 | perror(mtab_file); |
60 | } | 60 | } |
61 | 61 | ||
62 | /* | ||
63 | * Given a block device, find the mount table entry if that block device | ||
64 | * is mounted. | ||
65 | * | ||
66 | * Given any other file (or directory), find the mount table entry for its | ||
67 | * filesystem. | ||
68 | */ | ||
69 | static struct mntent * | ||
70 | findMountPoint(const char * name, const char * table) | ||
71 | { | ||
72 | struct stat s; | ||
73 | dev_t mountDevice; | ||
74 | FILE* mountTable; | ||
75 | struct mntent* mountEntry; | ||
76 | |||
77 | if ( stat(name, &s) != 0 ) | ||
78 | return 0; | ||
79 | |||
80 | if ( (s.st_mode & S_IFMT) == S_IFBLK ) | ||
81 | mountDevice = s.st_rdev; | ||
82 | else | ||
83 | mountDevice = s.st_dev; | ||
84 | |||
85 | |||
86 | if ( (mountTable = setmntent(table, "r")) == 0 ) | ||
87 | return 0; | ||
88 | |||
89 | while ( (mountEntry = getmntent(mountTable)) != 0 ) { | ||
90 | if ( strcmp(name, mountEntry->mnt_dir) == 0 || | ||
91 | strcmp(name, mountEntry->mnt_fsname) == 0 ) /* String match. */ | ||
92 | break; | ||
93 | if ( stat(mountEntry->mnt_fsname, &s) == 0 && | ||
94 | s.st_rdev == mountDevice ) /* Match the device. */ | ||
95 | break; | ||
96 | if ( stat(mountEntry->mnt_dir, &s) == 0 && | ||
97 | s.st_dev == mountDevice ) /* Match the directory's mount point. */ | ||
98 | break; | ||
99 | } | ||
100 | endmntent(mountTable); | ||
101 | return mountEntry; | ||
102 | } | ||
103 | |||
104 | extern void | 62 | extern void |
105 | write_mtab(char* blockDevice, char* directory, | 63 | write_mtab(char* blockDevice, char* directory, |
106 | char* filesystemType, long flags, char* string_flags) | 64 | char* filesystemType, long flags, char* string_flags) |