Cygwin: simplify some function names

Remove "32" or "64" from each of the following names: acl32,
aclcheck32, aclfrommode32, aclfrompbits32, aclfromtext32, aclsort32,
acltomode32, acltopbits32, acltotext32, facl32, fchown32, fcntl64,
fstat64, _fstat64, _fstat64_r, ftruncate64, getgid32, getgrent32,
getgrgid32, getgrnam32, getgroups32, getpwuid32, getpwuid_r32,
getuid32, getuid32, initgroups32, lseek64, lstat64, mknod32, mmap64,
setegid32, seteuid32, setgid32, setgroups32, setregid32, setreuid32,
setuid32, stat64, _stat64_r, truncate64.

Remove prototypes and macro definitions of these names.

Remove "#ifndef __INSIDE_CYGWIN__" from some headers so that the new
names will be available when compiling Cygwin.

Remove aliases that are no longer needed.

Include <unistd.h> in fhandler_clipboard.cc for the declarations of
geteuid and getegid.
This commit is contained in:
Ken Brown 2022-05-22 15:18:48 -04:00
parent 7c0de0af97
commit 2d9b48760c
37 changed files with 124 additions and 260 deletions

View File

@ -55,10 +55,10 @@ struct passwd {
char *pw_shell; /* default shell */
};
#ifndef __INSIDE_CYGWIN__
struct passwd *getpwuid (uid_t);
struct passwd *getpwnam (const char *);
#ifndef __INSIDE_CYGWIN__
#if __MISC_VISIBLE || __POSIX_VISIBLE
int getpwnam_r (const char *, struct passwd *,
char *, size_t , struct passwd **);

View File

@ -142,7 +142,7 @@ int mkfifo (const char *__path, mode_t __mode );
int stat (const char *__restrict __path, struct stat *__restrict __sbuf );
mode_t umask (mode_t __mask );
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__)
int lstat (const char *__restrict __path, struct stat *__restrict __buf );
int mknod (const char *__path, mode_t __mode, dev_t __dev );
#endif

View File

@ -21,9 +21,7 @@ int access (const char *__path, int __amode);
unsigned alarm (unsigned __secs);
int chdir (const char *__path);
int chmod (const char *__path, mode_t __mode);
#if !defined(__INSIDE_CYGWIN__)
int chown (const char *__path, uid_t __owner, gid_t __group);
#endif
#if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
int chroot (const char *__path);
#endif
@ -79,11 +77,9 @@ int fchdir (int __fildes);
#if __POSIX_VISIBLE >= 199309
int fchmod (int __fildes, mode_t __mode);
#endif
#if !defined(__INSIDE_CYGWIN__)
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
int fchown (int __fildes, uid_t __owner, gid_t __group);
#endif
#endif
#if __ATFILE_VISIBLE
int fchownat (int __dirfd, const char *__path, uid_t __owner, gid_t __group, int __flags);
#endif
@ -106,11 +102,9 @@ int getdomainname (char *__name, size_t __len);
#if __BSD_VISIBLE
int getentropy (void *, size_t);
#endif
#if !defined(__INSIDE_CYGWIN__)
gid_t getegid (void);
uid_t geteuid (void);
gid_t getgid (void);
#endif
int getgroups (int __gidsetsize, gid_t __grouplist[]);
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
long gethostid (void);
@ -135,9 +129,7 @@ pid_t getppid (void);
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
pid_t getsid (pid_t);
#endif
#if !defined(__INSIDE_CYGWIN__)
uid_t getuid (void);
#endif
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
char * getusershell (void);
#endif
@ -151,11 +143,9 @@ int isatty (int __fildes);
#if __BSD_VISIBLE
int issetugid (void);
#endif
#if !defined(__INSIDE_CYGWIN__)
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
int lchown (const char *__path, uid_t __owner, gid_t __group);
#endif
#endif
int link (const char *__path1, const char *__path2);
#if __ATFILE_VISIBLE
int linkat (int __dirfd1, const char *__path1, int __dirfd2, const char *__path2, int __flags);
@ -198,13 +188,11 @@ int ruserok (const char *rhost, int superuser, const char *ruser, const char *lu
#if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
void * sbrk (ptrdiff_t __incr);
#endif
#if !defined(__INSIDE_CYGWIN__)
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
int setegid (gid_t __gid);
int seteuid (uid_t __uid);
#endif
int setgid (gid_t __gid);
#endif
#if __BSD_VISIBLE
int setgroups (int ngroups, const gid_t *grouplist);
#endif
@ -215,14 +203,12 @@ int setpgid (pid_t __pid, pid_t __pgid);
#if __SVID_VISIBLE || __XSI_VISIBLE >= 500
int setpgrp (void);
#endif
#if (__BSD_VISIBLE || __XSI_VISIBLE >= 4) && !defined(__INSIDE_CYGWIN__)
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
int setregid (gid_t __rgid, gid_t __egid);
int setreuid (uid_t __ruid, uid_t __euid);
#endif
pid_t setsid (void);
#if !defined(__INSIDE_CYGWIN__)
int setuid (uid_t __uid);
#endif
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
void setusershell (void);
#endif

View File

@ -146,17 +146,6 @@ typedef struct __posix_spawn_file_actions_entry {
* Spawn routines
*/
#if defined (__CYGWIN__) && defined (__i386__)
extern int getgid32 (void);
extern int getuid32 (void);
extern int setegid32 (gid_t egid);
extern int seteuid32 (uid_t euid);
#define setegid setegid32
#define seteuid seteuid32
#define getgid getgid32
#define getuid getuid32
#endif
static int
process_spawnattr(const posix_spawnattr_t sa)
{

View File

@ -102,7 +102,7 @@ public:
user_groups groups; /* Primary and supp SIDs */
HANDLE external_token; /* token from set_impersonation_token call */
HANDLE internal_token; /* password-less token fetched in seteuid32 */
HANDLE internal_token; /* password-less token fetched in seteuid */
HANDLE curr_primary_token; /* Just a copy of external or internal token */
HANDLE curr_imp_token; /* impersonation token derived from primary
token */

View File

@ -29,8 +29,6 @@ void dlmalloc_stats ();
#if defined (DLMALLOC_VERSION) /* Building malloc.cc */
extern "C" void __set_ENOMEM ();
void *mmap64 (void *, size_t, int, int, int, off_t);
# define mmap mmap64
# define MALLOC_FAILURE_ACTION __set_ENOMEM ()
# define USE_DL_PREFIX 1

View File

@ -36,8 +36,8 @@ ipc_set_proc_info (proc &blk, bool in_fork = false)
{
blk.cygpid = getpid ();
blk.winpid = GetCurrentProcessId ();
blk.uid = geteuid32 ();
blk.gid = getegid32 ();
blk.uid = geteuid ();
blk.gid = getegid ();
blk.gidcnt = 0;
blk.gidlist = NULL;
blk.is_admin = false;

View File

@ -17,7 +17,7 @@ details. */
#include "cygtls.h"
extern "C" int
fcntl64 (int fd, int cmd, ...)
fcntl (int fd, int cmd, ...)
{
int res = -1;
intptr_t arg = 0;
@ -79,5 +79,4 @@ fcntl64 (int fd, int cmd, ...)
return res;
}
EXPORT_ALIAS (fcntl64, fcntl)
EXPORT_ALIAS (fcntl64, _fcntl)
EXPORT_ALIAS (fcntl, _fcntl)

View File

@ -1272,8 +1272,8 @@ fhandler_base::fstat (struct stat *buf)
break;
}
buf->st_uid = geteuid32 ();
buf->st_gid = getegid32 ();
buf->st_uid = geteuid ();
buf->st_gid = getegid ();
buf->st_nlink = 1;
buf->st_blksize = PREFERRED_IO_BLKSIZE;

View File

@ -18,6 +18,7 @@ details. */
#include "cygheap.h"
#include "child_info.h"
#include <sys/clipboard.h>
#include <unistd.h>
/*
* Robert Collins:
@ -159,8 +160,8 @@ int __reg2
fhandler_dev_clipboard::fstat (struct stat *buf)
{
buf->st_mode = S_IFCHR | STD_RBITS | STD_WBITS | S_IWGRP | S_IWOTH;
buf->st_uid = geteuid32 ();
buf->st_gid = getegid32 ();
buf->st_uid = geteuid ();
buf->st_gid = getegid ();
buf->st_nlink = 1;
buf->st_blksize = PREFERRED_IO_BLKSIZE;

View File

@ -1013,7 +1013,7 @@ cant_access_acl:
switch (cmd)
{
case SETACL:
if (!aclsort32 (nentries, 0, aclbufp))
if (!aclsort (nentries, 0, aclbufp))
{
bool rw = false;
res = setacl (get_handle (), pc, nentries, aclbufp, rw);

View File

@ -1049,7 +1049,7 @@ peb_teb_rinse_repeat:
if (mount_table->conv_to_posix_path (dosname,
posix_modname, 0))
sys_wcstombs (posix_modname, NT_MAX_PATH, dosname);
stat64 (posix_modname, &st);
stat (posix_modname, &st);
}
else if (!threads.fill_if_match (cur.abase, mb.Type,
posix_modname)

View File

@ -47,8 +47,8 @@ fhandler_dev_raw::fstat (struct stat *buf)
if (get_major () == DEV_SD_HIGHPART_END && get_minor () == 9999)
buf->st_ino = get_ino ();
buf->st_uid = geteuid32 ();
buf->st_gid = getegid32 ();
buf->st_uid = geteuid ();
buf->st_gid = getegid ();
buf->st_nlink = 1;
buf->st_blksize = PREFERRED_IO_BLKSIZE;
time_as_timestruc_t (&buf->st_ctim);

View File

@ -395,8 +395,8 @@ void
fhandler_socket_local::af_local_set_sockpair_cred ()
{
sec_pid = sec_peer_pid = getpid ();
sec_uid = sec_peer_uid = geteuid32 ();
sec_gid = sec_peer_gid = getegid32 ();
sec_uid = sec_peer_uid = geteuid ();
sec_gid = sec_peer_gid = getegid ();
}
void
@ -592,8 +592,8 @@ void
fhandler_socket_local::af_local_set_cred ()
{
sec_pid = getpid ();
sec_uid = geteuid32 ();
sec_gid = getegid32 ();
sec_uid = geteuid ();
sec_gid = getegid ();
sec_peer_pid = (pid_t) 0;
sec_peer_uid = (uid_t) -1;
sec_peer_gid = (gid_t) -1;

View File

@ -1818,7 +1818,7 @@ fhandler_pty_slave::facl (int cmd, int nentries, aclent_t *aclbufp)
switch (cmd)
{
case SETACL:
if (!aclsort32 (nentries, 0, aclbufp))
if (!aclsort (nentries, 0, aclbufp))
set_errno (ENOTSUP);
break;
case GETACL:

View File

@ -101,9 +101,6 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010/05/12 17:44:00 gordon Ex
#include "cygheap.h"
#include "cygwin/version.h"
#define getpwuid(uid) getpwuid32 (uid)
#define getuid() getuid32 ()
#define CCHAR(c) (ignore_case_with_glob ? towlower (CHAR (c)) : CHAR (c))
#define Cchar(c) (ignore_case_with_glob ? towlower (c) : (c))
#endif
@ -868,7 +865,7 @@ g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
}
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
return CYGWIN_gl_stat (gl_lstat);
return(lstat64(buf, sb));
return(lstat(buf, sb));
}
static int
@ -882,7 +879,7 @@ g_stat(Char *fn, struct stat *sb, glob_t *pglob)
}
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
return CYGWIN_gl_stat (gl_stat);
return(stat64(buf, sb));
return(stat(buf, sb));
}
static const Char *

View File

@ -300,15 +300,13 @@ getgr_cp (struct group *tempgr)
}
extern "C" struct group *
getgrgid32 (gid_t gid)
getgrgid (gid_t gid)
{
struct group *tempgr = internal_getgrgid (gid);
pthread_testcancel ();
return getgr_cp (tempgr);
}
EXPORT_ALIAS (getgrgid32, getgrgid)
extern "C" int
getgrnam_r (const char *nam, struct group *grp, char *buffer,
size_t bufsize, struct group **result)
@ -340,15 +338,13 @@ getgrnam_r (const char *nam, struct group *grp, char *buffer,
}
extern "C" struct group *
getgrnam32 (const char *name)
getgrnam (const char *name)
{
struct group *tempgr = internal_getgrnam (name);
pthread_testcancel ();
return getgr_cp (tempgr);
}
EXPORT_ALIAS (getgrnam32, getgrnam)
/* getgrent functions are not reentrant. */
static gr_ent grent;
@ -459,13 +455,11 @@ setgrent ()
}
extern "C" struct group *
getgrent32 (void)
getgrent (void)
{
return grent.getgrent ();
}
EXPORT_ALIAS (getgrent32, getgrent)
extern "C" void
endgrent (void)
{
@ -646,15 +640,13 @@ out:
}
extern "C" int
getgroups32 (int gidsetsize, gid_t *grouplist)
getgroups (int gidsetsize, gid_t *grouplist)
{
cyg_ldap cldap;
return internal_getgroups (gidsetsize, grouplist, &cldap);
}
EXPORT_ALIAS (getgroups32, getgroups)
/* Core functionality of initgroups and getgrouplist. */
static void
get_groups (const char *user, gid_t gid, cygsidlist &gsids)
@ -673,7 +665,7 @@ get_groups (const char *user, gid_t gid, cygsidlist &gsids)
}
extern "C" int
initgroups32 (const char *user, gid_t gid)
initgroups (const char *user, gid_t gid)
{
assert (user != NULL);
cygsidlist tmp_gsids (cygsidlist_auto, 12);
@ -687,8 +679,6 @@ initgroups32 (const char *user, gid_t gid)
return 0;
}
EXPORT_ALIAS (initgroups32, initgroups)
extern "C" int
getgrouplist (const char *user, gid_t gid, gid_t *groups, int *ngroups)
{
@ -725,11 +715,11 @@ getgrouplist (const char *user, gid_t gid, gid_t *groups, int *ngroups)
return ret;
}
/* setgroups32: standards? */
/* setgroups: standards? */
extern "C" int
setgroups32 (int ngroups, const gid_t *grouplist)
setgroups (int ngroups, const gid_t *grouplist)
{
syscall_printf ("setgroups32 (%d)", ngroups);
syscall_printf ("setgroups (%d)", ngroups);
if (ngroups < 0 || (ngroups > 0 && !grouplist))
{
set_errno (EINVAL);
@ -756,5 +746,3 @@ setgroups32 (int ngroups, const gid_t *grouplist)
cygheap->user.groups.update_supp (gsids);
return 0;
}
EXPORT_ALIAS (setgroups32, setgroups)

View File

@ -70,7 +70,6 @@ typedef struct acl {
mode_t a_perm; /* permissions */
} aclent_t;
#ifndef __INSIDE_CYGWIN__
extern int acl (const char *__path, int __cmd, int __nentries,
aclent_t *__aclbufp);
extern int facl (int __fd, int __cmd, int __nentries,
@ -87,7 +86,6 @@ extern int aclfrompbits (aclent_t *__aclbufp, int __nentries,
mode_t *__pbitsp);
extern char *acltotext (aclent_t *__aclbufp, int __aclcnt);
extern aclent_t *aclfromtext (char *__acltextp, int *__aclcnt);
#endif
#ifdef __cplusplus
}

View File

@ -16,13 +16,6 @@ details. */
extern "C" {
#endif
#ifdef __INSIDE_CYGWIN__
struct group * getgrgid32 (gid_t gid);
struct group * getgrnam32 (const char *name);
gid_t getgid32 ();
gid_t getegid32 ();
#endif
extern int getgrouplist (const char *, gid_t, gid_t *, int *);
#ifdef __cplusplus

View File

@ -32,16 +32,6 @@ struct stat
timestruc_t st_birthtim;
};
#if defined (__INSIDE_CYGWIN__) || defined (_LIBC)
extern int fstat64 (int fd, struct stat *buf);
extern int stat64 (const char *__restrict file_name,
struct stat *__restrict buf);
extern int lstat64 (const char *__restrict file_name,
struct stat *__restrict buf);
#endif
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec

View File

@ -74,9 +74,7 @@ extern "C" {
#define MADV_UNMERGEABLE 11
#endif
#ifndef __INSIDE_CYGWIN__
extern void *mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, off_t __off);
#endif
extern int munmap (void *__addr, size_t __len);
extern int mprotect (void *__addr, size_t __len, int __prot);
extern int msync (void *__addr, size_t __len, int __flags);

View File

@ -18,7 +18,7 @@ ftok (const char *path, int id)
{
struct stat statbuf;
key_t tmp;
if (stat64 (path, &statbuf))
if (stat (path, &statbuf))
{
/* stat set the appropriate errno for us */
return (key_t) -1;

View File

@ -58,17 +58,8 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/fts.c,v 1.39 2013/02/11 02:00:16 svnexp Exp
#define _open open
#define _close close
#define _dirfd dirfd
#ifdef __x86_64__
#define _fstat fstat
#else
extern int stat64 (const char *path, struct stat *buf);
extern int fstat64 (int fd, struct stat *buf);
extern int lstat64 (const char *path, struct stat *buf);
#define stat(a,b) stat64((a),(b))
#define _fstat(a,b) fstat64((a),(b))
#define lstat(a,b) lstat64((a),(b))
#endif
#else
#include "un-namespace.h"
#include "gen-private.h"

View File

@ -237,12 +237,12 @@ static int open_sock(struct sockaddr_in *CliAddr, int debug)
return -1;
}
/* Set non-blocking */
if (fcntl64(fd, F_SETFL, O_NONBLOCK) < 0) {
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
DPRINTF(debug, "fcntl: %s\n", strerror(errno));
return -1;
}
/* Set close on exec flag */
if (fcntl64(fd, F_SETFD, 1) == -1) {
if (fcntl(fd, F_SETFD, 1) == -1) {
DPRINTF(debug, "fcntl: %s\n", strerror(errno));
return -1;
}

View File

@ -103,7 +103,6 @@ extern "C" {
int cygwin_rresvport_af(int *alport, int family);
int cygwin_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
int cygwin_socket (int, int, int);
int seteuid32 (uid_t);
}
#endif
@ -200,7 +199,7 @@ cygwin_rcmd_af(char **ahost, in_port_t rport, const char *locuser,
NULL);
return (-1);
}
fcntl64(s, F_SETOWN, pid);
fcntl(s, F_SETOWN, pid);
if (cygwin_connect(s, ai->ai_addr, ai->ai_addrlen) >= 0)
break;
(void)close(s);
@ -458,10 +457,10 @@ again:
* reading an NFS mounted file system, can't read files that
* are protected read/write owner only.
*/
uid = geteuid32();
(void)seteuid32(pwd->pw_uid);
uid = geteuid();
(void)seteuid(pwd->pw_uid);
hostf = fopen(pbuf, "rt");
(void)seteuid32(uid);
(void)seteuid(uid);
if (hostf == NULL)
return (-1);
@ -470,11 +469,11 @@ again:
* user or root or if writeable by anyone but the owner, quit.
*/
cp = NULL;
if (lstat64(pbuf, &sbuf) < 0)
if (lstat(pbuf, &sbuf) < 0)
cp = ".rhosts lstat failed";
else if (!S_ISREG(sbuf.st_mode))
cp = ".rhosts not regular file";
else if (fstat64(fileno(hostf), &sbuf) < 0)
else if (fstat(fileno(hostf), &sbuf) < 0)
cp = ".rhosts fstat failed";
else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid)
cp = "bad .rhosts owner";

View File

@ -215,7 +215,7 @@ next:
break;
case PASSWD:
if ((*aname == 0 || strcmp(*aname, "anonymous")) &&
fstat64(fileno(cfile), &stb) >= 0 &&
fstat(fileno(cfile), &stb) >= 0 &&
(stb.st_mode & 077) != 0) {
warnx("Error: .netrc file is readable by others.");
warnx("Remove password or make file unreadable by others.");
@ -227,7 +227,7 @@ next:
}
break;
case ACCOUNT:
if (fstat64(fileno(cfile), &stb) >= 0
if (fstat(fileno(cfile), &stb) >= 0
&& (stb.st_mode & 077) != 0) {
warnx("Error: .netrc file is readable by others.");
warnx("Remove account or make file unreadable by others.");

View File

@ -100,7 +100,7 @@ _gettemp(char *path, int *doopen, int domkdir, size_t suffixlen, int flags)
if (*trv == '/')
{
*trv = '\0';
int rval = stat64 (path, &sbuf);
int rval = stat (path, &sbuf);
*trv = '/';
if (rval != 0)
return 0;
@ -131,7 +131,7 @@ _gettemp(char *path, int *doopen, int domkdir, size_t suffixlen, int flags)
if (errno != EEXIST)
return 0;
}
else if (lstat64 (path, &sbuf))
else if (lstat (path, &sbuf))
return errno == ENOENT;
/* If we have a collision, cycle through the space of filenames */

View File

@ -238,7 +238,7 @@ MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
If it failed, and addr was not NULL and flags is not MAP_FIXED,
try again with NULL address.
Note: Retrying the mapping might be unnecessary, now that mmap64 checks
Note: Retrying the mapping might be unnecessary, now that mmap checks
for a valid memory area first. */
SIZE_T commitsize = attached (prot) ? 0 : len;
status = NtMapViewOfSection (h, NtCurrentProcess (), &base, 0, commitsize,
@ -832,7 +832,7 @@ mmap_worker (mmap_list *map_list, fhandler_base *fh, caddr_t base, size_t len,
}
extern "C" void *
mmap64 (void *addr, size_t len, int prot, int flags, int fd, off_t off)
mmap (void *addr, size_t len, int prot, int flags, int fd, off_t off)
{
syscall_printf ("addr %p, len %lu, prot %y, flags %y, fd %d, off %Y",
addr, len, prot, flags, fd, off);
@ -1145,8 +1145,6 @@ out:
return ret;
}
EXPORT_ALIAS (mmap64, mmap)
/* munmap () removes all mmapped pages between addr and addr+len. */
extern "C" int
@ -1280,7 +1278,7 @@ mprotect (void *addr, size_t len, int prot)
syscall_printf ("mprotect (addr: %p, len %lu, prot %y)", addr, len, prot);
/* See comment in mmap64 for a description. */
/* See comment in mmap for a description. */
const size_t pagesize = wincap.allocation_granularity ();
if ((uintptr_t) addr % pagesize)
{

View File

@ -218,17 +218,15 @@ getpw_cp (struct passwd *temppw)
}
extern "C" struct passwd *
getpwuid32 (uid_t uid)
getpwuid (uid_t uid)
{
struct passwd *temppw = internal_getpwuid (uid);
pthread_testcancel ();
return getpw_cp (temppw);
}
EXPORT_ALIAS (getpwuid32, getpwuid)
extern "C" int
getpwuid_r32 (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
{
*result = NULL;
@ -260,8 +258,6 @@ getpwuid_r32 (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struc
return 0;
}
EXPORT_ALIAS (getpwuid_r32, getpwuid_r)
extern "C" struct passwd *
getpwnam (const char *name)
{

View File

@ -3720,8 +3720,8 @@ get_current_dir_name (void)
struct stat pwdbuf, cwdbuf;
if (pwd && strcmp (pwd, cwd) != 0
&& stat64 (pwd, &pwdbuf) == 0
&& stat64 (cwd, &cwdbuf) == 0
&& stat (pwd, &pwdbuf) == 0
&& stat (cwd, &cwdbuf) == 0
&& pwdbuf.st_dev == cwdbuf.st_dev
&& pwdbuf.st_ino == cwdbuf.st_ino)
{

View File

@ -117,14 +117,14 @@ public:
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = size;
return fcntl64 (fd, F_SETLKW, &fl);
return fcntl (fd, F_SETLKW, &fl);
}
int unlock (int fd)
{
if (!fl.l_len)
return 0;
fl.l_type = F_UNLCK;
return fcntl64 (fd, F_SETLKW, &fl);
return fcntl (fd, F_SETLKW, &fl);
}
};
@ -424,7 +424,7 @@ sem_open (const char *name, int oflag, ...)
/* Make certain initialization is complete */
for (i = 0; i < MAX_TRIES; i++)
{
if (stat64 (semname, &statbuff) == -1)
if (stat (semname, &statbuff) == -1)
{
if (errno == ENOENT && (oflag & O_CREAT))
{
@ -476,7 +476,7 @@ sem_open (const char *name, int oflag, ...)
return SEM_FAILED;
}
extern "C" off_t lseek64 (int, off_t, int);
extern "C" off_t lseek (int, off_t, int);
int
_sem_close (sem_t *sem, bool do_close)
@ -488,7 +488,7 @@ _sem_close (sem_t *sem, bool do_close)
if (semaphore::getinternal (sem, &fd, &sf.hash, &sf.luid, &sf.value) == -1)
return -1;
if (!file.lock (fd, sizeof sf)
&& lseek64 (fd, 0LL, SEEK_SET) != (off_t) -1
&& lseek (fd, 0LL, SEEK_SET) != (off_t) -1
&& write (fd, &sf, sizeof sf) == sizeof sf)
ret = do_close ? semaphore::close (sem) : 0;

View File

@ -1186,7 +1186,7 @@ out:
memcpy (aclbufp, lacl, pos * sizeof (aclent_t));
for (idx = 0; idx < pos; ++idx)
aclbufp[idx].a_perm &= S_IRWXO;
aclsort32 (pos, 0, aclbufp);
aclsort (pos, 0, aclbufp);
}
if (std_acl)
*std_acl = standard_ACEs_only;
@ -1207,7 +1207,7 @@ getacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp)
}
extern "C" int
acl32 (const char *path, int cmd, int nentries, aclent_t *aclbufp)
acl (const char *path, int cmd, int nentries, aclent_t *aclbufp)
{
int res = -1;
@ -1229,7 +1229,7 @@ acl32 (const char *path, int cmd, int nentries, aclent_t *aclbufp)
}
extern "C" int
facl32 (int fd, int cmd, int nentries, aclent_t *aclbufp)
facl (int fd, int cmd, int nentries, aclent_t *aclbufp)
{
cygheap_fdget cfd (fd);
if (cfd < 0)
@ -1401,7 +1401,7 @@ __aclcheck (aclent_t *aclbufp, int nentries, int *which, bool posix)
}
extern "C" int
aclcheck32 (aclent_t *aclbufp, int nentries, int *which)
aclcheck (aclent_t *aclbufp, int nentries, int *which)
{
return __aclcheck (aclbufp, nentries, which, false);
}
@ -1466,10 +1466,10 @@ __aclsort (int nentries, aclent_t *aclbufp)
}
extern "C" int
aclsort32 (int nentries, int calclass, aclent_t *aclbufp)
aclsort (int nentries, int calclass, aclent_t *aclbufp)
{
if (!aclbufp || nentries < MIN_ACL_ENTRIES
|| aclcheck32 (aclbufp, nentries, NULL))
|| aclcheck (aclbufp, nentries, NULL))
{
set_errno (EINVAL);
return -1;
@ -1481,7 +1481,7 @@ aclsort32 (int nentries, int calclass, aclent_t *aclbufp)
}
extern "C" int
acltomode32 (aclent_t *aclbufp, int nentries, mode_t *modep)
acltomode (aclent_t *aclbufp, int nentries, mode_t *modep)
{
int pos;
@ -1520,7 +1520,7 @@ acltomode32 (aclent_t *aclbufp, int nentries, mode_t *modep)
}
extern "C" int
aclfrommode32 (aclent_t *aclbufp, int nentries, mode_t *modep)
aclfrommode (aclent_t *aclbufp, int nentries, mode_t *modep)
{
int pos;
@ -1557,15 +1557,15 @@ aclfrommode32 (aclent_t *aclbufp, int nentries, mode_t *modep)
}
extern "C" int
acltopbits32 (aclent_t *aclbufp, int nentries, mode_t *pbitsp)
acltopbits (aclent_t *aclbufp, int nentries, mode_t *pbitsp)
{
return acltomode32 (aclbufp, nentries, pbitsp);
return acltomode (aclbufp, nentries, pbitsp);
}
extern "C" int
aclfrompbits32 (aclent_t *aclbufp, int nentries, mode_t *pbitsp)
aclfrompbits (aclent_t *aclbufp, int nentries, mode_t *pbitsp)
{
return aclfrommode32 (aclbufp, nentries, pbitsp);
return aclfrommode (aclbufp, nentries, pbitsp);
}
static char *
@ -1635,7 +1635,7 @@ __acltotext (aclent_t *aclbufp, int aclcnt, const char *prefix, char separator,
int options)
{
if (!aclbufp || aclcnt < 0 || aclcnt > MAX_ACL_ENTRIES
|| (aclcnt > 0 && aclsort32 (aclcnt, 0, aclbufp)))
|| (aclcnt > 0 && aclsort (aclcnt, 0, aclbufp)))
{
set_errno (EINVAL);
return NULL;
@ -1776,7 +1776,7 @@ __acltotext (aclent_t *aclbufp, int aclcnt, const char *prefix, char separator,
}
extern "C" char *
acltotext32 (aclent_t *aclbufp, int aclcnt)
acltotext (aclent_t *aclbufp, int aclcnt)
{
return __acltotext (aclbufp, aclcnt, NULL, ',', 0);
}
@ -1960,18 +1960,7 @@ __aclfromtext (const char *acltextp, int *aclcnt, bool posix)
}
extern "C" aclent_t *
aclfromtext32 (char *acltextp, int *aclcnt)
aclfromtext (char *acltextp, int *aclcnt)
{
return (aclent_t *) __aclfromtext (acltextp, aclcnt, false);
}
EXPORT_ALIAS (acl32, acl)
EXPORT_ALIAS (facl32, facl)
EXPORT_ALIAS (aclcheck32, aclcheck)
EXPORT_ALIAS (aclsort32, aclsort)
EXPORT_ALIAS (acltomode32, acltomode)
EXPORT_ALIAS (aclfrommode32, aclfrommode)
EXPORT_ALIAS (acltopbits32, acltopbits)
EXPORT_ALIAS (aclfrompbits32, aclfrompbits)
EXPORT_ALIAS (acltotext32, acltotext)
EXPORT_ALIAS (aclfromtext32, aclfromtext)

View File

@ -364,8 +364,8 @@ set_security_attribute (path_conv &pc, int attribute, PSECURITY_ATTRIBUTES psa,
psa->lpSecurityDescriptor = sd.malloc (SECURITY_DESCRIPTOR_MIN_LENGTH);
RtlCreateSecurityDescriptor ((PSECURITY_DESCRIPTOR) psa->lpSecurityDescriptor,
SECURITY_DESCRIPTOR_REVISION);
psa->lpSecurityDescriptor = set_posix_access (attribute, geteuid32 (),
getegid32 (), NULL, 0,
psa->lpSecurityDescriptor = set_posix_access (attribute, geteuid (),
getegid (), NULL, 0,
sd, false);
}

View File

@ -438,8 +438,6 @@ bool authz_get_user_attribute (mode_t *attribute, PSECURITY_DESCRIPTOR psd,
/* sec_acl.cc */
struct acl;
extern "C" int aclsort32 (int, int, struct acl *);
extern "C" int acl32 (const char *, int, int, struct acl *);
int searchace (struct acl *, int, int, uid_t id = ILLEGAL_UID);
PSECURITY_DESCRIPTOR set_posix_access (mode_t, uid_t, gid_t, struct acl *, int,
security_descriptor &, bool);

View File

@ -1599,7 +1599,7 @@ EXPORT_ALIAS (open, _open )
EXPORT_ALIAS (open, _open64 )
extern "C" off_t
lseek64 (int fd, off_t pos, int dir)
lseek (int fd, off_t pos, int dir)
{
off_t res;
@ -1624,9 +1624,8 @@ lseek64 (int fd, off_t pos, int dir)
return res;
}
EXPORT_ALIAS (lseek64, _lseek64)
EXPORT_ALIAS (lseek64, lseek)
EXPORT_ALIAS (lseek64, _lseek)
EXPORT_ALIAS (lseek, _lseek64)
EXPORT_ALIAS (lseek, _lseek)
extern "C" int
close (int fd)
@ -1726,23 +1725,19 @@ chown_worker (const char *name, unsigned fmode, uid_t uid, gid_t gid)
}
extern "C" int
chown32 (const char * name, uid_t uid, gid_t gid)
chown (const char * name, uid_t uid, gid_t gid)
{
return chown_worker (name, PC_SYM_FOLLOW, uid, gid);
}
EXPORT_ALIAS (chown32, chown)
extern "C" int
lchown32 (const char * name, uid_t uid, gid_t gid)
lchown (const char * name, uid_t uid, gid_t gid)
{
return chown_worker (name, PC_SYM_NOFOLLOW, uid, gid);
}
EXPORT_ALIAS (lchown32, lchown)
extern "C" int
fchown32 (int fd, uid_t uid, gid_t gid)
fchown (int fd, uid_t uid, gid_t gid)
{
cygheap_fdget cfd (fd);
if (cfd < 0)
@ -1762,8 +1757,6 @@ fchown32 (int fd, uid_t uid, gid_t gid)
return res;
}
EXPORT_ALIAS (fchown32, fchown)
/* umask: POSIX 5.3.3.1 */
extern "C" mode_t
umask (mode_t mask)
@ -1859,7 +1852,7 @@ fhandler_base::stat_fixup (struct stat *buf)
{
if (!dev_st_inited)
{
stat64 ("/dev", &dev_st);
stat ("/dev", &dev_st);
dev_st_inited = true;
}
buf->st_dev = dev_st.st_dev;
@ -1882,7 +1875,7 @@ fhandler_base::stat_fixup (struct stat *buf)
}
extern "C" int
fstat64 (int fd, struct stat *buf)
fstat (int fd, struct stat *buf)
{
int res;
@ -1902,17 +1895,16 @@ fstat64 (int fd, struct stat *buf)
}
extern "C" int
_fstat64_r (struct _reent *ptr, int fd, struct stat *buf)
_fstat_r (struct _reent *ptr, int fd, struct stat *buf)
{
int ret;
if ((ret = fstat64 (fd, buf)) == -1)
if ((ret = fstat (fd, buf)) == -1)
ptr->_errno = get_errno ();
return ret;
}
EXPORT_ALIAS (fstat64, fstat)
EXPORT_ALIAS (_fstat64_r, _fstat_r)
EXPORT_ALIAS (_fstat_r, _fstat64_r)
/* fsync: P96 6.6.1.1 */
extern "C" int
@ -2043,7 +2035,7 @@ stat_worker (path_conv &pc, struct stat *buf)
}
extern "C" int
stat64 (const char *__restrict name, struct stat *__restrict buf)
stat (const char *__restrict name, struct stat *__restrict buf)
{
syscall_printf ("entering");
path_conv pc (name, PC_SYM_FOLLOW | PC_POSIX | PC_KEEP_HANDLE
@ -2053,22 +2045,21 @@ stat64 (const char *__restrict name, struct stat *__restrict buf)
}
extern "C" int
_stat64_r (struct _reent *__restrict ptr, const char *__restrict name,
_stat_r (struct _reent *__restrict ptr, const char *__restrict name,
struct stat *buf)
{
int ret;
if ((ret = stat64 (name, buf)) == -1)
if ((ret = stat (name, buf)) == -1)
ptr->_errno = get_errno ();
return ret;
}
EXPORT_ALIAS (stat64, stat)
EXPORT_ALIAS (_stat64_r, _stat_r)
EXPORT_ALIAS (_stat_r, _stat64_r)
/* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */
extern "C" int
lstat64 (const char *__restrict name, struct stat *__restrict buf)
lstat (const char *__restrict name, struct stat *__restrict buf)
{
syscall_printf ("entering");
path_conv pc (name, PC_SYM_NOFOLLOW | PC_POSIX | PC_KEEP_HANDLE,
@ -2076,8 +2067,6 @@ lstat64 (const char *__restrict name, struct stat *__restrict buf)
return stat_worker (pc, buf);
}
EXPORT_ALIAS (lstat64, lstat)
extern "C" int
access (const char *fn, int flags)
{
@ -3055,7 +3044,7 @@ posix_fallocate (int fd, off_t offset, off_t len)
}
extern "C" int
ftruncate64 (int fd, off_t length)
ftruncate (int fd, off_t length)
{
int res = -1;
cygheap_fdget cfd (fd);
@ -3074,11 +3063,9 @@ ftruncate64 (int fd, off_t length)
return res;
}
EXPORT_ALIAS (ftruncate64, ftruncate)
/* truncate: Provided by SVR4 and 4.3+BSD. Not part of POSIX.1 or XPG3 */
extern "C" int
truncate64 (const char *pathname, off_t length)
truncate (const char *pathname, off_t length)
{
int fd;
int res = -1;
@ -3087,7 +3074,7 @@ truncate64 (const char *pathname, off_t length)
if (fd != -1)
{
res = ftruncate64 (fd, length);
res = ftruncate (fd, length);
close (fd);
}
syscall_printf ("%R = truncate(%s, %D)", res, pathname, length);
@ -3095,8 +3082,6 @@ truncate64 (const char *pathname, off_t length)
return res;
}
EXPORT_ALIAS (truncate64, truncate)
extern "C" long
_get_osfhandle (int fd)
{
@ -3293,7 +3278,7 @@ mknod_worker (path_conv &pc, mode_t mode, _major_t major, _minor_t minor)
}
extern "C" int
mknod32 (const char *path, mode_t mode, dev_t dev)
mknod (const char *path, mode_t mode, dev_t dev)
{
__try
{
@ -3354,17 +3339,15 @@ mknod32 (const char *path, mode_t mode, dev_t dev)
return -1;
}
EXPORT_ALIAS (mknod32, mknod)
extern "C" int
mkfifo (const char *path, mode_t mode)
{
return mknod32 (path, (mode & ~S_IFMT) | S_IFIFO, 0);
return mknod (path, (mode & ~S_IFMT) | S_IFIFO, 0);
}
/* seteuid: standards? */
extern "C" int
seteuid32 (uid_t uid)
seteuid (uid_t uid)
{
debug_printf ("uid: %u myself->uid: %u myself->gid: %u",
uid, myself->uid, myself->gid);
@ -3568,13 +3551,11 @@ seteuid32 (uid_t uid)
return 0;
}
EXPORT_ALIAS (seteuid32, seteuid)
/* setuid: POSIX 4.2.2.1 */
extern "C" int
setuid32 (uid_t uid)
setuid (uid_t uid)
{
int ret = seteuid32 (uid);
int ret = seteuid (uid);
if (!ret)
{
cygheap->user.real_uid = myself->uid;
@ -3585,20 +3566,18 @@ setuid32 (uid_t uid)
return ret;
}
EXPORT_ALIAS (setuid32, setuid)
extern "C" int
setreuid32 (uid_t ruid, uid_t euid)
setreuid (uid_t ruid, uid_t euid)
{
int ret = 0;
bool tried = false;
uid_t old_euid = myself->uid;
if (ruid != ILLEGAL_UID && cygheap->user.real_uid != ruid && euid != ruid)
tried = !(ret = seteuid32 (ruid));
tried = !(ret = seteuid (ruid));
if (!ret && euid != ILLEGAL_UID)
ret = seteuid32 (euid);
if (tried && (ret || euid == ILLEGAL_UID) && seteuid32 (old_euid))
ret = seteuid (euid);
if (tried && (ret || euid == ILLEGAL_UID) && seteuid (old_euid))
system_printf ("Cannot restore original euid %u", old_euid);
if (!ret && ruid != ILLEGAL_UID)
cygheap->user.real_uid = ruid;
@ -3606,11 +3585,9 @@ setreuid32 (uid_t ruid, uid_t euid)
return ret;
}
EXPORT_ALIAS (setreuid32, setreuid)
/* setegid: from System V. */
extern "C" int
setegid32 (gid_t gid)
setegid (gid_t gid)
{
debug_printf ("new egid: %u current: %u", gid, myself->gid);
@ -3658,32 +3635,28 @@ setegid32 (gid_t gid)
return 0;
}
EXPORT_ALIAS (setegid32, setegid)
/* setgid: POSIX 4.2.2.1 */
extern "C" int
setgid32 (gid_t gid)
setgid (gid_t gid)
{
int ret = setegid32 (gid);
int ret = setegid (gid);
if (!ret)
cygheap->user.real_gid = myself->gid;
return ret;
}
EXPORT_ALIAS (setgid32, setgid)
extern "C" int
setregid32 (gid_t rgid, gid_t egid)
setregid (gid_t rgid, gid_t egid)
{
int ret = 0;
bool tried = false;
gid_t old_egid = myself->gid;
if (rgid != ILLEGAL_GID && cygheap->user.real_gid != rgid && egid != rgid)
tried = !(ret = setegid32 (rgid));
tried = !(ret = setegid (rgid));
if (!ret && egid != ILLEGAL_GID)
ret = setegid32 (egid);
if (tried && (ret || egid == ILLEGAL_GID) && setegid32 (old_egid))
ret = setegid (egid);
if (tried && (ret || egid == ILLEGAL_GID) && setegid (old_egid))
system_printf ("Cannot restore original egid %u", old_egid);
if (!ret && rgid != ILLEGAL_GID)
cygheap->user.real_gid = rgid;
@ -3691,8 +3664,6 @@ setregid32 (gid_t rgid, gid_t egid)
return ret;
}
EXPORT_ALIAS (setregid32, setregid)
/* chroot: privileged Unix system call. */
/* FIXME: Not privileged here. How should this be done? */
extern "C" int
@ -3896,13 +3867,13 @@ locked_append (int fd, const void * buf, size_t size)
int count = 0;
do
if ((lock_buffer.l_start = lseek64 (fd, 0, SEEK_END)) != (off_t) -1
&& fcntl64 (fd, F_SETLKW, &lock_buffer) != -1)
if ((lock_buffer.l_start = lseek (fd, 0, SEEK_END)) != (off_t) -1
&& fcntl (fd, F_SETLKW, &lock_buffer) != -1)
{
if (lseek64 (fd, 0, SEEK_END) != (off_t) -1)
if (lseek (fd, 0, SEEK_END) != (off_t) -1)
write (fd, buf, size);
lock_buffer.l_type = F_UNLCK;
fcntl64 (fd, F_SETLK, &lock_buffer);
fcntl (fd, F_SETLK, &lock_buffer);
break;
}
while (count++ < 1000
@ -4394,22 +4365,22 @@ popen (const char *command, const char *in_type)
end of the pipe. Otherwise don't pass our end of the pipe to the
child process. */
if (pipe_flags & O_CLOEXEC)
fcntl64 (__std[stdchild], F_SETFD, 0);
fcntl (__std[stdchild], F_SETFD, 0);
else
fcntl64 (myfd, F_SETFD, FD_CLOEXEC);
fcntl (myfd, F_SETFD, FD_CLOEXEC);
/* Also don't pass the file handle currently associated with stdin/stdout
to the child. This function may actually fail if the stdchild fd
is closed. But that's ok. */
int stdchild_state = fcntl64 (stdchild, F_GETFD, 0);
fcntl64 (stdchild, F_SETFD, stdchild_state | FD_CLOEXEC);
int stdchild_state = fcntl (stdchild, F_GETFD, 0);
fcntl (stdchild, F_SETFD, stdchild_state | FD_CLOEXEC);
/* Start a shell process to run the given command without forking. */
pid_t pid = ch_spawn.worker ("/bin/sh", argv, cur_environ (), _P_NOWAIT,
__std[0], __std[1]);
/* Reinstate the close-on-exec state */
fcntl64 (stdchild, F_SETFD, stdchild_state);
fcntl (stdchild, F_SETFD, stdchild_state);
/* If pid >= 0 then spawn_guts succeeded. */
if (pid >= 0)
@ -4711,7 +4682,7 @@ fstatat (int dirfd, const char *__restrict pathname, struct stat *__restrict st,
cwdstuff::cwd_lock.release ();
}
else
return fstat64 (dirfd, st);
return fstat (dirfd, st);
}
path_conv pc (path, ((flags & AT_SYMLINK_NOFOLLOW)
? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW)
@ -4869,7 +4840,7 @@ mknodat (int dirfd, const char *pathname, mode_t mode, dev_t dev)
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
__leave;
return mknod32 (path, mode, dev);
return mknod (path, mode, dev);
}
__except (EFAULT) {}
__endtry

View File

@ -279,37 +279,29 @@ getlogin (void)
}
extern "C" uid_t
getuid32 (void)
getuid (void)
{
return cygheap->user.real_uid;
}
EXPORT_ALIAS (getuid32, getuid)
extern "C" gid_t
getgid32 (void)
getgid (void)
{
return cygheap->user.real_gid;
}
EXPORT_ALIAS (getgid32, getgid)
extern "C" uid_t
geteuid32 (void)
geteuid (void)
{
return myself->uid;
}
EXPORT_ALIAS (geteuid32, geteuid)
extern "C" gid_t
getegid32 (void)
getegid (void)
{
return myself->gid;
}
EXPORT_ALIAS (getegid32, getegid)
/* Not quite right - cuserid can change, getlogin can't */
extern "C" char *
cuserid (char *src)

View File

@ -41,17 +41,10 @@ details. */
#ifdef __cplusplus
extern "C" {
#endif
uid_t getuid32 ();
uid_t geteuid32 ();
int seteuid32 (uid_t);
gid_t getegid32 (void);
struct passwd *getpwuid32 (uid_t);
struct passwd *getpwnam (const char *);
struct __sFILE64 *fopen64 (const char *, const char *);
struct hostent *cygwin_gethostbyname (const char *name);
/* Don't enforce definition of in_addr_t. */
uint32_t cygwin_inet_addr (const char *cp);
int fcntl64 (int fd, int cmd, ...);
#ifdef __cplusplus
}
#endif