"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fsutils.c" between
cryptmount-5.3.1.tar.gz and cryptmount-5.3.2.tar.gz

About: cryptmount allows any user to access encrypted filing systems on demand under GNU/Linux systems. It also assists the system administrator in creating and managing encrypted filesystems based on the kernels dm-crypt device-mapper target.

fsutils.c  (cryptmount-5.3.1):fsutils.c  (cryptmount-5.3.2)
skipping to change at line 439 skipping to change at line 439
* Check whether a filesystem target is mounted. * Check whether a filesystem target is mounted.
* *
* This will examine entries in /etc/mtab via getmntent(), * This will examine entries in /etc/mtab via getmntent(),
* looking for a filesystem whose major and minor device numbers * looking for a filesystem whose major and minor device numbers
* match those of the block device associated with the supplied target. * match those of the block device associated with the supplied target.
* *
* Note that this will return false for targets that refer * Note that this will return false for targets that refer
* to swap partitions, even if they are active. * to swap partitions, even if they are active.
*/ */
int is_mounted(const tgtdefn_t *tgt) int is_mounted(const tgtdefn_t *tgt)
{ int mounted=0; { int mounted = 0;
char *mntdev=NULL; char *mntdev = NULL;
struct mntent *mntinfo; struct mntent *mntinfo;
struct stat st_mtb, st_tgt; struct stat st_mtb, st_tgt;
FILE *fp; FILE *fp;
/* check if underlying device has been configured at all: */ /* check if underlying device has been configured at all: */
if (!is_configured(tgt->ident, NULL)) return 0; if (!is_configured(tgt->ident, NULL)) return 0;
/* find path to device that would have been mounted & device info: */ /* find path to device that would have been mounted & device info: */
devmap_path(&mntdev, tgt->ident); devmap_path(&mntdev, tgt->ident);
if (stat(mntdev, &st_tgt) != 0) return 0; if (stat(mntdev, &st_tgt) != 0) {
mounted = 0;
goto bail_out;
}
/* check entries in /etc/mtab: */ /* check entries in /etc/mtab: */
fp = setmntent(ETCMTAB, "r"); fp = setmntent(ETCMTAB, "r");
if (fp == NULL) { if (fp == NULL) {
return 0; /* indeterminate case - assume not mounted */ /* indeterminate case - assume not mounted */
mounted = 0;
goto bail_out;
} }
while ((mntinfo = getmntent(fp)) != NULL && !mounted) { while ((mntinfo = getmntent(fp)) != NULL && !mounted) {
if (stat(mntinfo->mnt_fsname, &st_mtb) != 0) continue; if (stat(mntinfo->mnt_fsname, &st_mtb) != 0) continue;
/* compare to mounted device on basis of kernel device maj/min: */ /* compare to mounted device on basis of kernel device maj/min: */
if (major(st_mtb.st_rdev) == major(st_tgt.st_rdev) if (major(st_mtb.st_rdev) == major(st_tgt.st_rdev)
&& minor(st_mtb.st_rdev) == minor(st_tgt.st_rdev)) { && minor(st_mtb.st_rdev) == minor(st_tgt.st_rdev)) {
mounted = 1; mounted = 1;
} }
} }
endmntent(fp); endmntent(fp);
bail_out:
if (mntdev) free((void*)mntdev);
return mounted; return mounted;
} }
int is_readonlyfs(const char *path) int is_readonlyfs(const char *path)
/*! Check if filesystem containing *path is read-only */ /*! Check if filesystem containing *path is read-only */
{ struct statvfs sbuff; { struct statvfs sbuff;
return (path == NULL return (path == NULL
|| (statvfs(path, &sbuff) != 0 || (statvfs(path, &sbuff) != 0
|| (sbuff.f_flag & ST_RDONLY) != 0)); || (sbuff.f_flag & ST_RDONLY) != 0));
 End of changes. 4 change blocks. 
4 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)