From 035df9eff5ad116d40599db4ebf9dd8e51734b9c Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 26 Jul 2003 05:38:51 +0000 Subject: [PATCH] * mount.cc (do_mount): Issue warning when using managed mount option on non-empty directory. --- winsup/utils/ChangeLog | 5 +++++ winsup/utils/mount.cc | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 0e3368085..1131bec27 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,8 @@ +2003-07-26 Christopher Faylor + + * mount.cc (do_mount): Issue warning when using managed mount option on + non-empty directory. + 2003-07-25 Christopher Faylor * configure.in: Use 'install-sh -c'. diff --git a/winsup/utils/mount.cc b/winsup/utils/mount.cc index 0cce584e6..2a7014986 100644 --- a/winsup/utils/mount.cc +++ b/winsup/utils/mount.cc @@ -16,6 +16,7 @@ details. */ #include #include #include +#include #ifdef errno #undef errno @@ -104,6 +105,25 @@ do_mount (const char *dev, const char *where, int flags) } } + if (!force && flags & MOUNT_ENC) + { + DIR *dd = opendir (dev); + if (dd) + { + struct dirent *d; + while ((d = readdir (dd))) + { + if (d->d_name[0] != '.') + /* fall through */; + else if (d->d_name[1] == '\0' + || (d->d_name[1] == '.' && d->d_name[2] == '\0')) + continue; + fprintf (stderr, "%s: error: don't use \"-o managed\" on non-empty directories\n", progname); + exit (1); + } + } + } + if (mount (dev, where, flags)) error (where);