This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Mount table in registry

Igor Pechtchanski <> writes:

> On Thu, 22 May 2003, Corinna Vinschen wrote:
> > On Thu, May 22, 2003 at 04:12:37PM +0200, Sebastian Miele wrote:
> > > Hi,
> > >
> > > the user documentation on the mount table
> > > ( says that the
> > > mount table is located under:
> > >
> > >   HKEY_CURRENT_USER/Software/Red Hat, Inc./Cygwin/mounts v<version>
> > >
> > > However, on my system it is located under:
> > >
> > >   HKEY_CURRENT_USER/Software/Cygnus Solutions/Cygwin/mounts v2
> > >
> > > Most probably the documentation has not been updated, yet.
> > >
> > > How likely is it that either the version (2) or the company (Red Hat,
> > > Inc./Cygnus Solutions) changes in the future?
> >
> > 100%
> >
> > Use mount.  Never rely on the registry.
> > Corinna
> Corinna and others,
> This is becoming an FAQ, so I'm going to feel the waters here...
> Would making a libmount.a (or, better yet, cygmount.dll) be a good
> idea?  Then programs can link against it and be guaranteed that they
> can read mounts or verify mount locations.  I know Cygwin exports
> getmntent() and the like, but the above would be something that
> doesn't depend on cygwin1.dll.  Setup.exe could then use it as well
> (although then it'd have to be a static lib).  Comments, flames?

The app I have in mind is the following: A non-cygwin application
which is linked against the mingw runtime and distributed under X11
license could use cygmount.dll in order to understand cygwin paths by
linking cygmount.dll at runtime if present, i.e. if cygwin is

The setup sources contain a file which basically already
provides the functionality needed for cygmount.dll.  ( also
contains a cygpath function.  However, it only converts absolute
cygwin paths and does not resolve symlinks, which is not enough for my
purpose.)  I think, using as a reference implementation,
cygmount.dll/libmount.a can be created easily.

If the resulting cygmount.dll will be distributed under the LGPL or
the X11 license in future versions of cygwin (so that any system with
cygwin1.dll installed also has cygmount.dll installed), I would do
that and add cygwin->windows path conversion functions which also
resolve symlinks.

Here is my proposal for an interface:

  /* Adds a new mount point to the registry.  Returns 0 on success. */
  int mount(const char* native, const char* posix, unsigned int flags);
  /* Removes an existing mount point from the registry.  Returns 0 on
     success. */
  int umount(const char* posix);
  struct mntent {
    char native[MAX_PATH];
    char posix[MAX_PATH];
    unsigned int flags;
  struct mnttable {
    struct mntent mntents[];
    unsigned int count;
    unsigned int current;  // for iteration, i.e. getmntent
  /* Reads the mount table from registry. */
  struct mnttable* read_mount_table();
  struct mnttable* free_mount_table();
  struct mnttable* setmntent();  /* Synonym for read_mount_table() */
  struct mnttable* endmntent(); /* Synonym for free_mount_table() */
  /* Iterates the mount points in the given mount table.  Returns NULL
     after an iteration is complete; the next call starts a new
     iteration. */
  struct mnttent* getmntent(struct mnttable*);

  /* Given an absolute cygwin path posix=/c1/.../cn, determines the
     longest prefix /c1/../cm which is a mount point in the mount table.
     Stores the corresponding source in native and sets rel to the
     beginning of the substring /cm+1/../cn in posix.  Returns 0 on
     success. */
  int resolve(const char* posix, char* native, const char**const rel);
  int resolve(struct mnttable*, const char* posix, char* native, const char**const rel);
  struct path_list {
    char* paths[];
    unsigned int count;
  void free_path_list(struct path_list*);
  /* Converts an absulute cygwin path to the corresponding absolute
     windows path.  If the corresponding windows path does not exist
     (due to cyclic or dead links) the result is non-zero.  */
  int conv_abs_posix_to_abs_native(const char* posix, char* native);
  /* Given a windows path of the form ./w, returns all symlink-free
     cygwin paths c with conv_abs_posix_to_abs_native(c)=cwd/w. */
  struct path_list* conv_rel_posix_to_abs_native();

Best wishes

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]