[PATCH] Add getmntent_r

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


And I missed a line in my dirty code example:

On Jun  5 14:42, Corinna Vinschen wrote:
>   What you want is more like this (untested):
> 
>   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_dir = stpcpy (mntbuf->mnt_fsname = buf, mnt->mnt_fsname);
>    mntbuf->mnt_type = stpcpy (mntbuf->mnt_dir, mnt->mnt_dir);
>    mntbuf->mnt_opts = stpcpy (mntbuf->mnt_type, mnt->mnt_type);

     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;


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