/* Common database routines for nss_db.
- Copyright (C) 2000, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2000-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
#include <errno.h>
#include <fcntl.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <sys/mman.h>
#include <not-cancel.h>
-#include <kernel-features.h>
#include "nss_db.h"
/* Open the database stored in FILE. If succesful, store either a
{
enum nss_status status = NSS_STATUS_UNAVAIL;
- int mode = O_RDONLY | O_LARGEFILE;
-#ifdef O_CLOEXEC
- mode |= O_CLOEXEC;
-#endif
- int fd = open_not_cancel_2 (file, mode);
+ int fd = __open_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1)
{
struct nss_db_header header;
status = NSS_STATUS_TRYAGAIN;
}
- close_not_cancel_no_status (fd);
+ __close_nocancel_nostatus (fd);
}
return status;
void
internal_endent (struct nss_db_map *mapping)
{
- munmap (mapping->header, mapping->len);
+ if (mapping->header != NULL)
+ {
+ munmap (mapping->header, mapping->len);
+ mapping->header = NULL;
+ }
}