diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index cca6875dc..60b180885 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2012-07-18 Yaakov Selkowitz + + * 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. + 2012-07-12 Corinna Vinschen * winlean.h: Make sure certain Windows macros are undefined again. diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 7084f49bd..acd043b30 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -738,6 +738,7 @@ _getlogin = getlogin NOSIGFE getlogin_r NOSIGFE getmntent SIGFE _getmntent = getmntent SIGFE +getmntent_r SIGFE getmode SIGFE _getmode = getmode SIGFE getnameinfo = cygwin_getnameinfo SIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 0e9ead932..7b85d881b 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -430,12 +430,13 @@ details. */ 259: Export pthread_sigqueue. 260: Export scandirat. 261: Export memrchr. + 262: Export getmntent_r. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 261 +#define CYGWIN_VERSION_API_MINOR 262 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/include/mntent.h b/winsup/cygwin/include/mntent.h index 8ad270ba0..5fb8e3a70 100644 --- a/winsup/cygwin/include/mntent.h +++ b/winsup/cygwin/include/mntent.h @@ -31,6 +31,7 @@ struct mntent #include FILE *setmntent (const char *__filep, const char *__type); struct mntent *getmntent (FILE *__filep); +struct mntent *getmntent_r (FILE *, struct mntent *, char *, int); int endmntent (FILE *__filep); #endif 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 *) { diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml index e9b4e085f..0c6f6e502 100644 --- a/winsup/cygwin/posix.sgml +++ b/winsup/cygwin/posix.sgml @@ -1115,6 +1115,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). get_phys_pages get_nprocs get_nprocs_conf + getmntent_r getopt_long getopt_long_only getpt diff --git a/winsup/cygwin/release/1.7.16 b/winsup/cygwin/release/1.7.16 index a55c8aeab..39bf8bd2f 100644 --- a/winsup/cygwin/release/1.7.16 +++ b/winsup/cygwin/release/1.7.16 @@ -1,7 +1,7 @@ What's new: ----------- -- New API: memrchr. +- New API: getmntent_r, memrchr. - Support ReFS.