2000-12-13 04:03:45 +08:00
|
|
|
/**
|
|
|
|
* \file system.h
|
|
|
|
*/
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
#ifndef H_SYSTEM
|
|
|
|
#define H_SYSTEM
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2002-06-21 01:17:23 +08:00
|
|
|
|
2002-05-03 06:16:30 +08:00
|
|
|
#if defined(__LCLINT__)
|
|
|
|
/*@-redef@*/
|
|
|
|
typedef unsigned int u_int32_t;
|
|
|
|
typedef unsigned short u_int16_t;
|
|
|
|
typedef unsigned char u_int8_t;
|
|
|
|
/*@-incondefs@*/ /* LCLint 3.0.0.15 */
|
|
|
|
typedef int int32_t;
|
|
|
|
/*@=incondefs@*/
|
2003-11-24 03:50:52 +08:00
|
|
|
/* XXX from /usr/include/bits/sigset.h */
|
|
|
|
/*@-sizeoftype@*/
|
|
|
|
# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned long int __val[_SIGSET_NWORDS];
|
|
|
|
} __sigset_t;
|
|
|
|
/*@=sizeoftype@*/
|
2002-05-03 06:16:30 +08:00
|
|
|
/*@=redef@*/
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <sys/stat.h>
|
1999-11-27 08:15:07 +08:00
|
|
|
#include <stdio.h>
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* <unistd.h> should be included before any preprocessor test
|
|
|
|
of _POSIX_VERSION. */
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
2001-10-14 03:35:58 +08:00
|
|
|
#if defined(__LCLINT__)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-superuser -declundef -incondefs @*/ /* LCL: modifies clause missing */
|
2001-10-14 03:35:58 +08:00
|
|
|
extern int chroot (const char *__path)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@globals errno, systemState @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies errno, systemState @*/;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@=superuser =declundef =incondefs @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
#endif
|
2002-04-12 00:55:19 +08:00
|
|
|
#if !defined(__GLIBC__) && !defined(__LCLINT__)
|
2002-04-09 06:52:45 +08:00
|
|
|
extern char ** environ;
|
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif
|
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#if TIME_WITH_SYS_TIME
|
|
|
|
# include <sys/time.h>
|
|
|
|
# include <time.h>
|
|
|
|
#else
|
|
|
|
# if HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
# else
|
|
|
|
# include <time.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NEED_TIMEZONE
|
|
|
|
extern time_t timezone;
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* Since major is a function on SVR4, we can't use `ifndef major'. */
|
|
|
|
#if MAJOR_IN_MKDEV
|
|
|
|
#include <sys/mkdev.h>
|
|
|
|
#define HAVE_MAJOR
|
|
|
|
#endif
|
|
|
|
#if MAJOR_IN_SYSMACROS
|
|
|
|
#include <sys/sysmacros.h>
|
|
|
|
#define HAVE_MAJOR
|
|
|
|
#endif
|
|
|
|
#ifdef major /* Might be defined in sys/types.h. */
|
|
|
|
#define HAVE_MAJOR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_MAJOR
|
|
|
|
#define major(dev) (((dev) >> 8) & 0xff)
|
|
|
|
#define minor(dev) ((dev) & 0xff)
|
|
|
|
#define makedev(maj, min) (((maj) << 8) | (min))
|
|
|
|
#endif
|
|
|
|
#undef HAVE_MAJOR
|
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#ifdef HAVE_UTIME_H
|
|
|
|
#include <utime.h>
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# if !STDC_HEADERS && HAVE_MEMORY_H
|
|
|
|
# include <memory.h>
|
|
|
|
# endif
|
|
|
|
# include <string.h>
|
|
|
|
#else
|
|
|
|
# include <strings.h>
|
|
|
|
char *memchr ();
|
|
|
|
#endif
|
|
|
|
|
2001-10-14 03:35:58 +08:00
|
|
|
#if !defined(HAVE_STPCPY)
|
|
|
|
char * stpcpy(/*@out@*/ char * dest, const char * src);
|
1999-12-02 04:00:39 +08:00
|
|
|
#endif
|
|
|
|
|
2001-10-14 03:35:58 +08:00
|
|
|
#if !defined(HAVE_STPNCPY)
|
|
|
|
char * stpncpy(/*@out@*/ char * dest, const char * src, size_t n);
|
2000-02-28 04:50:52 +08:00
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <errno.h>
|
|
|
|
#ifndef errno
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-declundef @*/
|
1998-07-26 05:00:26 +08:00
|
|
|
extern int errno;
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@=declundef @*/
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif
|
|
|
|
|
2003-04-17 06:13:18 +08:00
|
|
|
#if defined(__LCLINT__)
|
|
|
|
/*@-declundef @*/
|
|
|
|
/*@exits@*/
|
|
|
|
extern void error(int status, int errnum, const char *format, ...)
|
|
|
|
__attribute__ ((__format__ (__printf__, 3, 4)))
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/;
|
|
|
|
/*@=declundef @*/
|
|
|
|
#else
|
|
|
|
#if HAVE_ERROR && HAVE_ERROR_H
|
|
|
|
#include <error.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2003-05-01 16:09:16 +08:00
|
|
|
#if HAVE___SECURE_GETENV && !defined(__LCLINT__)
|
2003-05-01 04:04:58 +08:00
|
|
|
#define getenv(_s) __secure_getenv(_s)
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#ifdef STDC_HEADERS
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@-macrounrecog -incondefs -globuse -mustmod @*/ /* FIX: shrug */
|
1998-07-26 05:00:26 +08:00
|
|
|
#define getopt system_getopt
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@=macrounrecog =incondefs =globuse =mustmod @*/
|
1998-11-19 05:41:05 +08:00
|
|
|
/*@-skipansiheaders@*/
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <stdlib.h>
|
1998-11-19 05:41:05 +08:00
|
|
|
/*@=skipansiheaders@*/
|
1998-07-26 05:00:26 +08:00
|
|
|
#undef getopt
|
2001-10-14 03:35:58 +08:00
|
|
|
#if defined(__LCLINT__)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-declundef -incondefs @*/ /* LCL: modifies clause missing */
|
2001-10-14 03:35:58 +08:00
|
|
|
extern char * realpath (const char * file_name, /*@out@*/ char * resolved_name)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@globals errno, fileSystem @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@requires maxSet(resolved_name) >= (PATH_MAX - 1); @*/
|
|
|
|
/*@modifies *resolved_name, errno, fileSystem @*/;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@=declundef =incondefs @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
#else /* not STDC_HEADERS */
|
1999-04-14 19:28:31 +08:00
|
|
|
char *getenv (const char *name);
|
2001-10-14 03:35:58 +08:00
|
|
|
#if ! HAVE_REALPATH
|
|
|
|
char *realpath(const char *path, char resolved_path []);
|
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif /* STDC_HEADERS */
|
|
|
|
|
2000-06-13 06:13:10 +08:00
|
|
|
/* XXX solaris2.5.1 has not */
|
|
|
|
#if !defined(EXIT_FAILURE)
|
|
|
|
#define EXIT_FAILURE 1
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#else
|
|
|
|
#include <sys/file.h>
|
|
|
|
#endif
|
|
|
|
|
2001-06-04 21:55:58 +08:00
|
|
|
#if !defined(SEEK_SET) && !defined(__LCLINT__)
|
1998-07-26 05:00:26 +08:00
|
|
|
#define SEEK_SET 0
|
|
|
|
#define SEEK_CUR 1
|
|
|
|
#define SEEK_END 2
|
|
|
|
#endif
|
2001-06-04 21:55:58 +08:00
|
|
|
#if !defined(F_OK) && !defined(__LCLINT__)
|
1998-07-26 05:00:26 +08:00
|
|
|
#define F_OK 0
|
|
|
|
#define X_OK 1
|
|
|
|
#define W_OK 2
|
|
|
|
#define R_OK 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
# include <dirent.h>
|
|
|
|
# define NLENGTH(direct) (strlen((direct)->d_name))
|
|
|
|
#else /* not HAVE_DIRENT_H */
|
|
|
|
# define dirent direct
|
|
|
|
# define NLENGTH(direct) ((direct)->d_namlen)
|
|
|
|
# ifdef HAVE_SYS_NDIR_H
|
|
|
|
# include <sys/ndir.h>
|
|
|
|
# endif /* HAVE_SYS_NDIR_H */
|
|
|
|
# ifdef HAVE_SYS_DIR_H
|
|
|
|
# include <sys/dir.h>
|
|
|
|
# endif /* HAVE_SYS_DIR_H */
|
|
|
|
# ifdef HAVE_NDIR_H
|
|
|
|
# include <ndir.h>
|
|
|
|
# endif /* HAVE_NDIR_H */
|
|
|
|
#endif /* HAVE_DIRENT_H */
|
|
|
|
|
2001-10-14 03:35:58 +08:00
|
|
|
#if defined(__LCLINT__)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-declundef -incondefs @*/ /* LCL: missing annotation */
|
2002-04-15 05:48:44 +08:00
|
|
|
/*@only@*/ /*@out@*/ void * alloca (size_t __size)
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@ensures maxSet(result) == (__size - 1) @*/
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@*/;
|
|
|
|
/*@=declundef =incondefs @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
# undef alloca
|
|
|
|
# define alloca __builtin_alloca
|
|
|
|
#else
|
|
|
|
# ifdef HAVE_ALLOCA_H
|
|
|
|
# include <alloca.h>
|
|
|
|
# else
|
|
|
|
# ifndef _AIX
|
|
|
|
/* AIX alloca decl has to be the first thing in the file, bletch! */
|
|
|
|
char *alloca ();
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2002-01-19 06:51:30 +08:00
|
|
|
#if defined (__GLIBC__) && defined(__LCLINT__)
|
|
|
|
/*@-declundef@*/
|
|
|
|
/*@unchecked@*/
|
|
|
|
extern __const __int32_t *__ctype_tolower;
|
|
|
|
/*@unchecked@*/
|
|
|
|
extern __const __int32_t *__ctype_toupper;
|
|
|
|
/*@=declundef@*/
|
2002-06-20 03:27:20 +08:00
|
|
|
#endif
|
2002-01-19 06:51:30 +08:00
|
|
|
|
2002-06-20 03:27:20 +08:00
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#if defined (__GLIBC__) && defined(__LCLINT__)
|
2002-01-19 06:51:30 +08:00
|
|
|
/*@-exportlocal@*/
|
|
|
|
extern int isalnum(int) __THROW /*@*/;
|
|
|
|
extern int iscntrl(int) __THROW /*@*/;
|
|
|
|
extern int isgraph(int) __THROW /*@*/;
|
|
|
|
extern int islower(int) __THROW /*@*/;
|
|
|
|
extern int ispunct(int) __THROW /*@*/;
|
|
|
|
extern int isxdigit(int) __THROW /*@*/;
|
|
|
|
extern int isascii(int) __THROW /*@*/;
|
|
|
|
extern int toascii(int) __THROW /*@*/;
|
|
|
|
extern int _toupper(int) __THROW /*@*/;
|
|
|
|
extern int _tolower(int) __THROW /*@*/;
|
|
|
|
/*@=exportlocal@*/
|
|
|
|
|
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
#if HAVE_SYS_MMAN_H && !defined(__LCLINT__)
|
1998-07-31 06:09:42 +08:00
|
|
|
#include <sys/mman.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
|
|
|
|
#if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_SYS_UTSNAME_H
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#if HAVE_SYS_WAIT_H
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#endif
|
|
|
|
|
1998-10-08 22:59:17 +08:00
|
|
|
#if HAVE_GETOPT_H
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@-noparams@*/
|
1998-10-08 22:59:17 +08:00
|
|
|
#include <getopt.h>
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@=noparams@*/
|
1998-10-08 22:59:17 +08:00
|
|
|
#endif
|
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#if HAVE_GRP_H
|
|
|
|
#include <grp.h>
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#if HAVE_LIMITS_H
|
|
|
|
#include <limits.h>
|
|
|
|
#endif
|
|
|
|
|
1999-09-21 11:22:53 +08:00
|
|
|
#if HAVE_ERR_H
|
|
|
|
#include <err.h>
|
|
|
|
#endif
|
|
|
|
|
2001-10-14 03:35:58 +08:00
|
|
|
#if HAVE_MALLOC_H && !defined(__LCLINT__)
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
|
|
|
|
2004-01-05 22:09:47 +08:00
|
|
|
#if WITH_SELINUX
|
|
|
|
#include <selinux/selinux.h>
|
|
|
|
#else
|
|
|
|
typedef char * security_context_t;
|
|
|
|
|
|
|
|
#define freecon(_c)
|
|
|
|
|
|
|
|
#define getfilecon(_fn, _c) (-1)
|
|
|
|
#define lgetfilecon(_fn, _c) (-1)
|
|
|
|
#define fgetfilecon(_fd, _c) (-1)
|
|
|
|
|
|
|
|
#define setfilecon(_fn, _c) (-1)
|
|
|
|
#define lsetfilecon(_fn, _c) (-1)
|
|
|
|
#define fsetfilecon(_fd, _c) (-1)
|
|
|
|
|
2004-02-16 12:57:25 +08:00
|
|
|
#define getcon(_c) (-1)
|
|
|
|
#define getexeccon(_c) (-1)
|
|
|
|
#define setexeccon(_c) (-1)
|
|
|
|
|
2004-01-05 22:09:47 +08:00
|
|
|
#define security_check_context(_c) (0)
|
2004-02-16 12:57:25 +08:00
|
|
|
#define security_getenforce() (0)
|
2004-01-05 22:09:47 +08:00
|
|
|
|
|
|
|
#define is_selinux_enabled() (-1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__LCLINT__)
|
|
|
|
/*@-incondefs@*/
|
|
|
|
extern void freecon(/*@only@*/ security_context_t con)
|
|
|
|
/*@modifies con @*/;
|
|
|
|
|
|
|
|
extern int getfilecon(const char *path, /*@out@*/ security_context_t *con)
|
|
|
|
/*@modifies *con @*/;
|
|
|
|
extern int lgetfilecon(const char *path, /*@out@*/ security_context_t *con)
|
|
|
|
/*@modifies *con @*/;
|
|
|
|
extern int fgetfilecon(int fd, /*@out@*/ security_context_t *con)
|
|
|
|
/*@modifies *con @*/;
|
|
|
|
|
|
|
|
extern int setfilecon(const char *path, security_context_t con)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/;
|
|
|
|
extern int lsetfilecon(const char *path, security_context_t con)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/;
|
|
|
|
extern int fsetfilecon(int fd, security_context_t con)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/;
|
|
|
|
|
2004-02-16 12:57:25 +08:00
|
|
|
extern int getcon(/*@out@*/ security_context_t *con)
|
|
|
|
/*@modifies *con @*/;
|
|
|
|
extern int getexeccon(/*@out@*/ security_context_t *con)
|
|
|
|
/*@modifies *con @*/;
|
|
|
|
extern int setexeccon(security_context_t con)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/;
|
|
|
|
|
2004-01-05 22:09:47 +08:00
|
|
|
extern int security_check_context(security_context_t con)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/;
|
2004-02-16 12:57:25 +08:00
|
|
|
extern int security_getenforce(void)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/;
|
2004-01-05 22:09:47 +08:00
|
|
|
|
|
|
|
extern int is_selinux_enabled(void)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/;
|
|
|
|
/*@=incondefs@*/
|
|
|
|
#endif
|
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-declundef -incondefs @*/ /* FIX: these are macros */
|
2001-09-25 05:53:14 +08:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
/*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@globals errno @*/
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@ensures maxSet(result) == (size - 1) @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies errno @*/;
|
2001-09-25 05:53:14 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
/*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@ensures maxSet(result) == (nmemb - 1) @*/
|
2001-09-25 05:53:14 +08:00
|
|
|
/*@*/;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo Annotate ptr with returned/out.
|
|
|
|
*/
|
|
|
|
/*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
|
|
|
|
size_t size)
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@ensures maxSet(result) == (size - 1) @*/
|
2001-09-25 05:53:14 +08:00
|
|
|
/*@modifies *ptr @*/;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
/*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
|
|
|
|
/*@*/;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@=declundef =incondefs @*/
|
2001-09-25 05:53:14 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
/*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
|
|
|
|
/*@*/;
|
1999-09-21 11:22:53 +08:00
|
|
|
|
1999-09-12 08:41:51 +08:00
|
|
|
#if HAVE_MCHECK_H
|
|
|
|
#include <mcheck.h>
|
2001-10-14 03:35:58 +08:00
|
|
|
#if defined(__LCLINT__)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-declundef -incondefs @*/ /* LCL: missing annotations */
|
2001-10-14 03:35:58 +08:00
|
|
|
#if 0
|
|
|
|
enum mcheck_status
|
|
|
|
{
|
|
|
|
MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
|
|
|
|
MCHECK_OK, /* Block is fine. */
|
|
|
|
MCHECK_FREE, /* Block freed twice. */
|
|
|
|
MCHECK_HEAD, /* Memory before the block was clobbered. */
|
|
|
|
MCHECK_TAIL /* Memory after the block was clobbered. */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int mcheck (void (*__abortfunc) (enum mcheck_status))
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals internalState@*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies internalState @*/;
|
|
|
|
extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals internalState@*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies internalState @*/;
|
|
|
|
extern void mcheck_check_all (void)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals internalState@*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies internalState @*/;
|
|
|
|
extern enum mcheck_status mprobe (void *__ptr)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals internalState@*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies internalState @*/;
|
|
|
|
extern void mtrace (void)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals internalState@*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies internalState @*/;
|
|
|
|
extern void muntrace (void)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals internalState@*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies internalState @*/;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@=declundef =incondefs @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
#endif /* defined(__LCLINT__) */
|
1999-09-21 11:22:53 +08:00
|
|
|
|
|
|
|
/* Memory allocation via macro defs to get meaningful locations from mtrace() */
|
2001-09-25 05:53:14 +08:00
|
|
|
#if defined(__GNUC__)
|
2000-04-26 03:41:37 +08:00
|
|
|
#define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
|
|
|
|
#define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
|
|
|
|
#define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
|
|
|
|
#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
|
2001-09-25 05:53:14 +08:00
|
|
|
#endif /* defined(__GNUC__) */
|
|
|
|
#endif /* HAVE_MCHECK_H */
|
1999-09-21 11:22:53 +08:00
|
|
|
|
1999-09-26 23:04:03 +08:00
|
|
|
/* Retrofit glibc __progname */
|
|
|
|
#if defined __GLIBC__ && __GLIBC__ >= 2
|
2000-05-25 01:53:35 +08:00
|
|
|
#if __GLIBC_MINOR__ >= 1
|
|
|
|
#define __progname __assert_program_name
|
|
|
|
#endif
|
1999-09-26 23:04:03 +08:00
|
|
|
#define setprogname(pn)
|
|
|
|
#else
|
1999-09-27 01:28:00 +08:00
|
|
|
#define __progname program_name
|
1999-09-26 23:04:03 +08:00
|
|
|
#define setprogname(pn) \
|
1999-09-27 01:28:00 +08:00
|
|
|
{ if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
|
1999-09-26 23:04:03 +08:00
|
|
|
else __progname = pn; \
|
|
|
|
}
|
|
|
|
#endif
|
2002-07-02 21:16:50 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
const char *__progname;
|
1999-09-26 23:04:03 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#if HAVE_NETDB_H
|
|
|
|
#include <netdb.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_PWD_H
|
|
|
|
#include <pwd.h>
|
|
|
|
#endif
|
|
|
|
|
1998-10-08 22:59:17 +08:00
|
|
|
/* Take care of NLS matters. */
|
|
|
|
|
|
|
|
#if HAVE_LOCALE_H
|
|
|
|
# include <locale.h>
|
|
|
|
#endif
|
|
|
|
#if !HAVE_SETLOCALE
|
|
|
|
# define setlocale(Category, Locale) /* empty */
|
|
|
|
#endif
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
#if ENABLE_NLS && !defined(__LCLINT__)
|
1998-10-08 22:59:17 +08:00
|
|
|
# include <libintl.h>
|
|
|
|
# define _(Text) gettext (Text)
|
|
|
|
#else
|
|
|
|
# undef bindtextdomain
|
|
|
|
# define bindtextdomain(Domain, Directory) /* empty */
|
|
|
|
# undef textdomain
|
|
|
|
# define textdomain(Domain) /* empty */
|
|
|
|
# define _(Text) Text
|
1999-10-01 00:56:05 +08:00
|
|
|
# undef dgettext
|
|
|
|
# define dgettext(DomainName, Text) Text
|
1998-10-08 22:59:17 +08:00
|
|
|
#endif
|
|
|
|
|
1998-12-02 01:18:38 +08:00
|
|
|
#define N_(Text) Text
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* ============== from misc/miscfn.h */
|
|
|
|
|
2004-10-14 23:09:07 +08:00
|
|
|
#if !defined(USE_GNU_GLOB) || defined(__LCLINT__)
|
1998-07-26 05:00:26 +08:00
|
|
|
#if HAVE_FNMATCH_H
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@-noparams@*/
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <fnmatch.h>
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@=noparams@*/
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif
|
|
|
|
|
2004-10-14 23:09:07 +08:00
|
|
|
#if HAVE_GLOB_H || defined(__LCLINT__)
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@-noparams@*/
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <glob.h>
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@=noparams@*/
|
2000-03-12 04:14:07 +08:00
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
#else
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@-noparams@*/
|
1998-07-26 05:00:26 +08:00
|
|
|
#include "misc/glob.h"
|
2000-03-12 04:14:07 +08:00
|
|
|
#include "misc/fnmatch.h"
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@=noparams@*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__LCLINT__)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-declundef -incondefs @*/ /* LCL: missing annotation */
|
2001-10-14 03:35:58 +08:00
|
|
|
#if 0
|
|
|
|
typedef /*@concrete@*/ struct
|
|
|
|
{
|
|
|
|
size_t gl_pathc;
|
|
|
|
char **gl_pathv;
|
|
|
|
size_t gl_offs;
|
|
|
|
int gl_flags;
|
|
|
|
|
|
|
|
void (*gl_closedir) (void *);
|
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
struct dirent *(*gl_readdir) (void *);
|
|
|
|
#else
|
|
|
|
void *(*gl_readdir) (void *);
|
|
|
|
#endif
|
|
|
|
ptr_t (*gl_opendir) (const char *);
|
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
int (*gl_lstat) (const char *restrict, struct stat *restrict);
|
|
|
|
int (*gl_stat) (const char *restrict, struct stat *restrict);
|
|
|
|
#else
|
|
|
|
int (*gl_lstat) (const char *restrict, void *restrict);
|
|
|
|
int (*gl_stat) (const char *restrict, void *restrict);
|
|
|
|
#endif
|
|
|
|
} glob_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/*@-constuse@*/
|
|
|
|
/*@constant int GLOB_ERR@*/
|
|
|
|
/*@constant int GLOB_MARK@*/
|
|
|
|
/*@constant int GLOB_NOSORT@*/
|
|
|
|
/*@constant int GLOB_DOOFFS@*/
|
|
|
|
/*@constant int GLOB_NOCHECK@*/
|
|
|
|
/*@constant int GLOB_APPEND@*/
|
|
|
|
/*@constant int GLOB_NOESCAPE@*/
|
|
|
|
/*@constant int GLOB_PERIOD@*/
|
|
|
|
|
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
/*@constant int GLOB_MAGCHAR@*/
|
|
|
|
/*@constant int GLOB_ALTDIRFUNC@*/
|
|
|
|
/*@constant int GLOB_BRACE@*/
|
|
|
|
/*@constant int GLOB_NOMAGIC@*/
|
|
|
|
/*@constant int GLOB_TILDE@*/
|
|
|
|
/*@constant int GLOB_ONLYDIR@*/
|
|
|
|
/*@constant int GLOB_TILDE_CHECK@*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*@constant int GLOB_FLAGS@*/
|
|
|
|
|
|
|
|
/*@constant int GLOB_NOSPACE@*/
|
|
|
|
/*@constant int GLOB_ABORTED@*/
|
|
|
|
/*@constant int GLOB_NOMATCH@*/
|
|
|
|
/*@constant int GLOB_NOSYS@*/
|
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
/*@constant int GLOB_ABEND@*/
|
|
|
|
#endif
|
|
|
|
/*@=constuse@*/
|
|
|
|
#endif
|
|
|
|
|
2004-10-10 01:29:22 +08:00
|
|
|
/*@-type@*/ /* XXX glob64_t */
|
|
|
|
extern int glob (const char *__pattern, int __flags,
|
|
|
|
int (*__errfunc) (const char *, int),
|
|
|
|
/*@out@*/ glob_t *__pglob)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@globals errno, fileSystem @*/
|
2004-10-10 01:29:22 +08:00
|
|
|
/*@modifies *__pglob, errno, fileSystem @*/;
|
2001-10-14 03:35:58 +08:00
|
|
|
/* XXX only annotation is a white lie */
|
2004-10-10 01:29:22 +08:00
|
|
|
extern void globfree (/*@only@*/ glob_t *__pglob)
|
|
|
|
/*@modifies *__pglob @*/;
|
|
|
|
/*@=type@*/
|
2001-10-14 03:35:58 +08:00
|
|
|
#ifdef _GNU_SOURCE
|
2004-10-10 01:29:22 +08:00
|
|
|
extern int glob_pattern_p (const char *__pattern, int __quote)
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@*/;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/*@-constuse@*/
|
|
|
|
/*@constant int FNM_PATHNAME@*/
|
|
|
|
/*@constant int FNM_NOESCAPE@*/
|
|
|
|
/*@constant int FNM_PERIOD@*/
|
|
|
|
|
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
/*@constant int FNM_FILE_NAME@*/ /* GNU extension */
|
|
|
|
/*@constant int FNM_LEADING_DIR@*/ /* GNU extension */
|
|
|
|
/*@constant int FNM_CASEFOLD@*/ /* GNU extension */
|
|
|
|
/*@constant int FNM_EXTMATCH@*/ /* GNU extension */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*@constant int FNM_NOMATCH@*/
|
|
|
|
|
|
|
|
#ifdef _XOPEN_SOURCE
|
|
|
|
/*@constant int FNM_NOSYS@*/ /* X/Open */
|
|
|
|
#endif
|
|
|
|
/*@=constuse@*/
|
|
|
|
#endif
|
|
|
|
|
2004-10-10 01:44:27 +08:00
|
|
|
extern int fnmatch (const char *__pattern, const char *__name, int __flags)
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@*/;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@=declundef =incondefs @*/
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ! HAVE_S_IFSOCK
|
2001-10-14 03:35:58 +08:00
|
|
|
#define S_IFSOCK (0xc000)
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ! HAVE_S_ISLNK
|
2001-10-14 03:35:58 +08:00
|
|
|
#define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ! HAVE_S_ISSOCK
|
2001-10-14 03:35:58 +08:00
|
|
|
#define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NEED_STRINGS_H
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NEED_MYREALLOC
|
|
|
|
#define realloc(ptr,size) myrealloc(ptr,size)
|
|
|
|
extern void *myrealloc(void *, size_t);
|
|
|
|
#endif
|
|
|
|
|
2000-02-28 04:50:52 +08:00
|
|
|
#if ! HAVE_SETENV
|
|
|
|
extern int setenv(const char *name, const char *value, int replace);
|
|
|
|
extern void unsetenv(const char *name);
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#if HAVE_SYS_SOCKET_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
|
|
|
|
2004-05-29 23:56:01 +08:00
|
|
|
#if HAVE_POLL_H
|
|
|
|
#include <poll.h>
|
|
|
|
#else
|
2001-10-14 06:01:38 +08:00
|
|
|
#if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
2004-05-29 23:56:01 +08:00
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-09-08 06:46:19 +08:00
|
|
|
/* Solaris <= 2.6 limits getpass return to only 8 chars */
|
|
|
|
#if HAVE_GETPASSPHRASE
|
|
|
|
#define getpass getpassphrase
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#if ! HAVE_LCHOWN
|
|
|
|
#define lchown chown
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_GETMNTINFO_R || HAVE_MNTCTL
|
|
|
|
# define GETMNTENT_ONE 0
|
|
|
|
# define GETMNTENT_TWO 0
|
|
|
|
# if HAVE_SYS_MNTCTL_H
|
|
|
|
# include <sys/mntctl.h>
|
|
|
|
# endif
|
|
|
|
# if HAVE_SYS_VMOUNT_H
|
|
|
|
# include <sys/vmount.h>
|
|
|
|
# endif
|
|
|
|
# if HAVE_SYS_MOUNT_H
|
|
|
|
# include <sys/mount.h>
|
|
|
|
# endif
|
|
|
|
#elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
|
|
|
|
# if HAVE_MNTENT_H
|
|
|
|
# include <stdio.h>
|
|
|
|
# include <mntent.h>
|
|
|
|
# define our_mntent struct mntent
|
|
|
|
# define our_mntdir mnt_dir
|
|
|
|
# elif HAVE_STRUCT_MNTTAB
|
|
|
|
# include <stdio.h>
|
|
|
|
# include <mnttab.h>
|
|
|
|
struct our_mntent {
|
|
|
|
char * our_mntdir;
|
|
|
|
};
|
|
|
|
struct our_mntent *getmntent(FILE *filep);
|
|
|
|
# define our_mntent struct our_mntent
|
|
|
|
# else
|
|
|
|
# include <stdio.h>
|
|
|
|
struct our_mntent {
|
|
|
|
char * our_mntdir;
|
|
|
|
};
|
|
|
|
struct our_mntent *getmntent(FILE *filep);
|
|
|
|
# define our_mntent struct our_mntent
|
|
|
|
# endif
|
|
|
|
# define GETMNTENT_ONE 1
|
|
|
|
# define GETMNTENT_TWO 0
|
|
|
|
#elif HAVE_SYS_MNTTAB_H
|
|
|
|
# include <stdio.h>
|
|
|
|
# include <sys/mnttab.h>
|
|
|
|
# define GETMNTENT_ONE 0
|
|
|
|
# define GETMNTENT_TWO 1
|
|
|
|
# define our_mntent struct mnttab
|
|
|
|
# define our_mntdir mnt_mountp
|
|
|
|
#else /* if !HAVE_MNTCTL */
|
|
|
|
# error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MOUNTED
|
|
|
|
#define MOUNTED "/etc/mnttab"
|
|
|
|
#endif
|
2003-02-15 07:03:35 +08:00
|
|
|
|
|
|
|
#if defined(__LCLINT__)
|
|
|
|
#define FILE_RCSID(id)
|
|
|
|
#else
|
|
|
|
#define FILE_RCSID(id) \
|
|
|
|
static inline const char *rcsid(const char *p) { \
|
|
|
|
return rcsid(p = id); \
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif /* H_SYSTEM */
|