diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-07-18 15:17:25 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-07-18 15:17:25 +0400 |
commit | 010f7350bad61a6d306a5ee755e7ed9e9761404a (patch) | |
tree | de26ee9e894f9bcc8b536fed14d17fbde8a3c569 /winsup/cygwin/mount.cc | |
parent | 03b7882aa0eb4b772f9bbf51df22145412bc27cd (diff) |
* cygwin.din (getmntent_r): Export.
* mount.cc (getmntent_r): New function.
* posix.sgml (std-gnu): Add getmntent_r.
* include/mntent.h (getmntent_r): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
Diffstat (limited to 'winsup/cygwin/mount.cc')
-rw-r--r-- | winsup/cygwin/mount.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index 17d9a45fa..efd4d41c8 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -1899,6 +1899,35 @@ getmntent (FILE *) return mount_table->getmntent (_my_tls.locals.iteration++); } +extern "C" struct mntent * +getmntent_r (FILE *, struct mntent *mntbuf, char *buf, int buflen) +{ + struct mntent *mnt = mount_table->getmntent (_my_tls.locals.iteration++); + int fsname_len, dir_len, type_len, opts_len, tmplen = buflen; + + if (!mnt) + return NULL; + + fsname_len = strlen (mnt->mnt_fsname) + 1; + dir_len = strlen (mnt->mnt_dir) + 1; + type_len = strlen (mnt->mnt_type) + 1; + opts_len = strlen (mnt->mnt_opts) + 1; + + snprintf (buf, buflen, "%s%c%s%c%s%c%s", mnt->mnt_fsname, '\0', + mnt->mnt_dir, '\0', mnt->mnt_type, '\0', mnt->mnt_opts); + + mntbuf->mnt_fsname = buf; + tmplen -= fsname_len; + mntbuf->mnt_dir = tmplen > 0 ? buf + fsname_len : (char *)""; + tmplen -= dir_len; + mntbuf->mnt_type = tmplen > 0 ? buf + fsname_len + dir_len : (char *)""; + tmplen -= type_len; + mntbuf->mnt_opts = tmplen > 0 ? buf + fsname_len + dir_len + type_len : (char *)""; + mntbuf->mnt_freq = mnt->mnt_freq; + mntbuf->mnt_passno = mnt->mnt_passno; + return mntbuf; +} + extern "C" int endmntent (FILE *) { |