[PATCH] Add getmntent_r

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Jun 5 14:54:00 GMT 2012


On Jun  5 16:39, Corinna Vinschen wrote:
> And I missed a line in my dirty code example:

And I missed to add a + 1 to the pointers returned from stpcpy.  Sigh.
Let's restart:

  struct mntent *mnt = mount_table->getmntent (_my_tls.locals.iteration++);
  if (!mnt)
    return NULL;
  int maxlen = strlen (mnt->mnt_fsname) + strlen (mnt->mnt_dir)
               + strlen (mnt->mnt_type) + strlen (mnt->mnt_opts) + 4;
  if (maxlen > buflen)
    return NULL;
  mntbuf->mnt_fsname = buf;
  mntbuf->mnt_dir = stpcpy (mntbuf->mnt_fsname, mnt->mnt_fsname) + 1;
  mntbuf->mnt_type = stpcpy (mntbuf->mnt_dir, mnt->mnt_dir) + 1;
  mntbuf->mnt_opts = stpcpy (mntbuf->mnt_type, mnt->mnt_type) + 1;
  stpcpy (mntbuf->mnt_opts, mnt->mnt_opts);
  mntbuf->mnt_freq = mnt->mnt_freq;
  mntbuf->mnt_passno = mnt->mnt_passno;
  memcpy (buf, tmpbuf, buflen);
  return mntbuf;

Sorry about that.  Hopefully you get the idea, regardless.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat



More information about the Cygwin-patches mailing list