This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: More: [1.7] packaging problem? Both /usr/bin/ and /usr/lib/ are non-empty
On May 11 16:31, Corinna Vinschen wrote:
> On May 11 15:55, Corinna Vinschen wrote:
> > On May 11 09:41, Christopher Faylor wrote:
> > > Wasn't the proposal to allow overriding of /usr/bin and /usr/lib if
> > > someone adds them to their fstab? I'd feel more comfortable with
> > > allowing the users control over that, I think. I can see why root would
> > > be a special case but I don't think that /usr/bin and /usr/lib need to
> > > be quite as special.
> >
> > Actually, the whole idea is to generate default /usr/bin and /usr/lib
> > entries. Whether or not they are readonly is probably not as important.
> > We lived with overridable entries all the time, so I have no strong
> > opinion. Just generating default entries seems to be a good thing.
>
> Uh, I forgot my own mail. Here's the reason again why R/O entries
> might be a good thing:
>
> http://cygwin.com/ml/cygwin-developers/2009-05/msg00004.html
I have a preliminary implementation ready which works around this problem
by *first*reading the fstab files, and afterwards creating /usr/bin and
/usr/lib entries from the / entry, if /usr/bin and /usr/lib entries are
not given in one of the fstab files.
Does that look ok?
Corinna
* mount.cc (mount_info::create_usr_entries): New function to create
/usr/bin and /usr/lib entries if they are missing in fstab files.
(mount_info::init): Simplify. Remove "Huh?" message. Call
create_usr_entries after reading fstab.
* mount.h (mount_info::create_usr_entries): Declare.
Index: mount.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/mount.cc,v
retrieving revision 1.35
diff -u -p -r1.35 mount.cc
--- mount.cc 4 May 2009 09:16:42 -0000 1.35
+++ mount.cc 11 May 2009 14:49:36 -0000
@@ -310,6 +310,44 @@ mount_info::create_root_entry (const PWC
cygdrive_len = strlen (cygdrive);
}
+inline void
+mount_info::create_usr_entries ()
+{
+ /* Create default /usr/bin and /usr/lib mount points if they are
+ missing in /etc/fstab. */
+ bool got_usr_bin = false;
+ bool got_usr_lib = false;
+ int root_idx = -1;
+
+ for (int i = 0; i < nmounts; i++)
+ {
+ if (!strcmp (mount[i].posix_path, "/"))
+ root_idx = i;
+ else if (!strcmp (mount[i].posix_path, "/usr/bin"))
+ got_usr_bin = true;
+ else if (!strcmp (mount[i].posix_path, "/usr/lib"))
+ got_usr_lib = true;
+ }
+ if (!got_usr_bin || !got_usr_lib)
+ {
+ char native[PATH_MAX];
+ char *p = stpcpy (native, mount[root_idx].native_path);
+ if (!got_usr_bin)
+ {
+ stpcpy (p, "\\bin");
+ mount_table->add_item (native, "/usr/bin",
+ MOUNT_SYSTEM | MOUNT_BINARY);
+ }
+ if (!got_usr_lib)
+ {
+ stpcpy (p, "\\lib");
+ mount_table->add_item (native, "/usr/lib",
+ MOUNT_SYSTEM | MOUNT_BINARY);
+ }
+
+ }
+}
+
/* init: Initialize the mount table. */
void
@@ -322,12 +360,9 @@ mount_info::init ()
pathend = wcpcpy (path, cygwin_shared->installation_root);
create_root_entry (path);
pathend = wcpcpy (pathend, L"\\etc\\fstab");
- if (from_fstab (false, path, pathend) /* The single | is correct! */
- | from_fstab (true, path, pathend))
- return;
-
- /* FIXME: Remove warning message before releasing 1.7.0. */
- small_printf ("Huh? No /etc/fstab file in %W? Using default root and cygdrive prefix...\n", path);
+ from_fstab (false, path, pathend);
+ from_fstab (true, path, pathend);
+ create_usr_entries ();
}
static void
Index: mount.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/mount.h,v
retrieving revision 1.4
diff -u -p -r1.4 mount.h
--- mount.h 4 May 2009 09:16:42 -0000 1.4
+++ mount.h 11 May 2009 14:49:36 -0000
@@ -140,6 +140,7 @@ class mount_info
void sort ();
void mount_slash ();
void create_root_entry (const PWCHAR root);
+ void create_usr_entries ();
bool from_fstab_line (char *line, bool user);
bool from_fstab (bool user, WCHAR [], PWCHAR);
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat