summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-11-06 06:07:27 +0000
committerEric Andersen <andersen@codepoet.org>1999-11-06 06:07:27 +0000
commit29d2e362dedf42d60ffebf6756144fb5449e753a (patch)
tree57ba26bdcf5dae8deb91a3d1a9b47bcc140689a0 /utility.c
parentbc3419069494fac078b316ce3a2f6a232c763c3e (diff)
downloadbusybox-w32-29d2e362dedf42d60ffebf6756144fb5449e753a.tar.gz
busybox-w32-29d2e362dedf42d60ffebf6756144fb5449e753a.tar.bz2
busybox-w32-29d2e362dedf42d60ffebf6756144fb5449e753a.zip
Fixed ln, df, and removed redundant stuff from mtab.
Diffstat (limited to '')
-rw-r--r--utility.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/utility.c b/utility.c
index 50d019254..97c597ee6 100644
--- a/utility.c
+++ b/utility.c
@@ -868,5 +868,64 @@ extern int replace_match(char *haystack, char *needle, char *newNeedle, int igno
868 868
869 869
870#endif 870#endif
871
872
873
874
875#if defined BB_DF | defined BB_MTAB
876/*
877 * Given a block device, find the mount table entry if that block device
878 * is mounted.
879 *
880 * Given any other file (or directory), find the mount table entry for its
881 * filesystem.
882 */
883extern struct mntent *findMountPoint(const char *name, const char *table)
884{
885 struct stat s;
886 dev_t mountDevice;
887 FILE *mountTable;
888 struct mntent *mountEntry;
889
890 if (stat(name, &s) != 0)
891 return 0;
892
893 if ((s.st_mode & S_IFMT) == S_IFBLK)
894 mountDevice = s.st_rdev;
895 else
896 mountDevice = s.st_dev;
897
898
899 if ((mountTable = setmntent(table, "r")) == 0)
900 return 0;
901
902 while ((mountEntry = getmntent(mountTable)) != 0) {
903 if (strcmp(name, mountEntry->mnt_dir) == 0
904 || strcmp(name, mountEntry->mnt_fsname) == 0) /* String match. */
905 break;
906 if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice) /* Match the device. */
907 break;
908 if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice) /* Match the directory's mount point. */
909 break;
910 }
911 endmntent(mountTable);
912 return mountEntry;
913}
914
915#endif
916
917
918
919#if !defined BB_MTAB && (defined BB_MOUNT || defined BB_DF )
920extern void whine_if_fstab_is_missing()
921{
922 struct stat statBuf;
923 if (stat("/etc/fstab", &statBuf) < 0)
924 fprintf(stderr, "/etc/fstab file missing -- install one to name /dev/root.\n\n");
925}
926#endif
927
928
871/* END CODE */ 929/* END CODE */
872 930
931