* cygwin.din: Add utmpx symbols.
* syscalls.cc: Include utmpx.h. Implement utmpx functions as stubs to utmp functions. (copy_ut_to_utx): New static function. (pututline): Change from void to struct utmp * as on Linux. (setutxent): New function. (endutxent): New function. (getutxent): New function. (getutxid): New function. (getutxline): New function. (pututxline): New function. * include/utmpx.h: New file. * include/cygwin/utmp.h: New file. * include/cygwin/version.h: Bump API minor number. * include/sys/utmp.h: Include cygwin/utmp.h. Move stuff common with utmpx functionality there. (pututline): Declare struct utmp *.
This commit is contained in:
parent
4931fc2b3a
commit
2ef89b220a
|
@ -1,3 +1,23 @@
|
|||
2004-12-15 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* cygwin.din: Add utmpx symbols.
|
||||
* syscalls.cc: Include utmpx.h. Implement utmpx functions as stubs
|
||||
to utmp functions.
|
||||
(copy_ut_to_utx): New static function.
|
||||
(pututline): Change from void to struct utmp * as on Linux.
|
||||
(setutxent): New function.
|
||||
(endutxent): New function.
|
||||
(getutxent): New function.
|
||||
(getutxid): New function.
|
||||
(getutxline): New function.
|
||||
(pututxline): New function.
|
||||
* include/utmpx.h: New file.
|
||||
* include/cygwin/utmp.h: New file.
|
||||
* include/cygwin/version.h: Bump API minor number.
|
||||
* include/sys/utmp.h: Include cygwin/utmp.h. Move stuff common with
|
||||
utmpx functionality there.
|
||||
(pututline): Declare struct utmp *.
|
||||
|
||||
2004-12-14 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* tty.cc (tty_list::terminate): Guard releasing the tty with tty_mutex.
|
||||
|
|
|
@ -404,6 +404,7 @@ endpwent NOSIGFE
|
|||
_endpwent = endpwent NOSIGFE
|
||||
endutent SIGFE
|
||||
_endutent = endutent SIGFE
|
||||
endutxent SIGFE
|
||||
envz_add SIGFE
|
||||
__envz_add = envz_add SIGFE
|
||||
envz_entry NOSIGFE
|
||||
|
@ -682,6 +683,9 @@ getutid SIGFE
|
|||
_getutid = getutid SIGFE
|
||||
getutline SIGFE
|
||||
_getutline = getutline SIGFE
|
||||
getutxent SIGFE
|
||||
getutxid SIGFE
|
||||
getutxline SIGFE
|
||||
getw SIGFE
|
||||
_getw = getw SIGFE
|
||||
getwd SIGFE
|
||||
|
@ -1067,6 +1071,7 @@ puts SIGFE
|
|||
_puts = puts SIGFE
|
||||
pututline SIGFE
|
||||
_pututline = pututline SIGFE
|
||||
pututxline SIGFE
|
||||
putw SIGFE
|
||||
_putw = putw SIGFE
|
||||
qsort NOSIGFE
|
||||
|
@ -1215,6 +1220,7 @@ _setuid = setuid SIGFE
|
|||
_setuid32 = setuid32 SIGFE
|
||||
setutent SIGFE
|
||||
_setutent = setutent SIGFE
|
||||
setutxent SIGFE
|
||||
setvbuf SIGFE
|
||||
_setvbuf = setvbuf SIGFE
|
||||
sexecl = sexecve_is_bad SIGFE
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/* cygwin/utmp.h
|
||||
|
||||
Copyright 2004 Red Hat, Inc.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
details. */
|
||||
|
||||
#ifndef CYGWIN_UTMP_H
|
||||
#define CYGWIN_UTMP_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <paths.h>
|
||||
|
||||
#define WTMP_FILE _PATH_WTMP
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UT_LINESIZE 16
|
||||
#define UT_NAMESIZE 16
|
||||
#define UT_HOSTSIZE 256
|
||||
#define UT_IDLEN 2
|
||||
|
||||
#define RUN_LVL 1
|
||||
#define BOOT_TIME 2
|
||||
#define NEW_TIME 3
|
||||
#define OLD_TIME 4
|
||||
|
||||
#define INIT_PROCESS 5
|
||||
#define LOGIN_PROCESS 6
|
||||
#define USER_PROCESS 7
|
||||
#define DEAD_PROCESS 8
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* CYGWIN_UTMP_H */
|
|
@ -244,12 +244,13 @@ details. */
|
|||
115: Export flockfile, ftrylockfile, funlockfile, getgrgid_r, getgrnam_r,
|
||||
getlogin_r.
|
||||
116: Export atoll.
|
||||
117: Export utmpx functions, Return utmp * from pututent.
|
||||
*/
|
||||
|
||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||
|
||||
#define CYGWIN_VERSION_API_MAJOR 0
|
||||
#define CYGWIN_VERSION_API_MINOR 116
|
||||
#define CYGWIN_VERSION_API_MINOR 117
|
||||
|
||||
/* There is also a compatibity version number associated with the
|
||||
shared memory regions. It is incremented when incompatible
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* sys/utmp.h
|
||||
|
||||
Copyright 2001 Red Hat, Inc.
|
||||
Copyright 2001, 2004 Red Hat, Inc.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
|
@ -9,21 +9,14 @@
|
|||
#ifndef UTMP_H
|
||||
#define UTMP_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <paths.h>
|
||||
#include <cygwin/utmp.h>
|
||||
|
||||
#define UTMP_FILE _PATH_UTMP
|
||||
#define WTMP_FILE _PATH_WTMP
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UT_LINESIZE 16
|
||||
#define UT_NAMESIZE 16
|
||||
#define UT_HOSTSIZE 256
|
||||
#define UT_IDLEN 2
|
||||
#define ut_name ut_user
|
||||
|
||||
struct utmp
|
||||
|
@ -38,22 +31,12 @@ struct utmp
|
|||
long ut_addr;
|
||||
};
|
||||
|
||||
#define RUN_LVL 1
|
||||
#define BOOT_TIME 2
|
||||
#define NEW_TIME 3
|
||||
#define OLD_TIME 4
|
||||
|
||||
#define INIT_PROCESS 5
|
||||
#define LOGIN_PROCESS 6
|
||||
#define USER_PROCESS 7
|
||||
#define DEAD_PROCESS 8
|
||||
|
||||
extern struct utmp *_getutline (struct utmp *);
|
||||
extern struct utmp *getutent (void);
|
||||
extern struct utmp *getutid (struct utmp *);
|
||||
extern struct utmp *getutline (struct utmp *);
|
||||
extern struct utmp *pututline (struct utmp *);
|
||||
extern void endutent (void);
|
||||
extern void pututline (struct utmp *);
|
||||
extern void setutent (void);
|
||||
extern void utmpname (const char *);
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* utmpx.h
|
||||
|
||||
Copyright 2004 Red Hat, Inc.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
details. */
|
||||
|
||||
#ifndef UTMPX_H
|
||||
#define UTMPX_H
|
||||
|
||||
#include <cygwin/utmp.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define UTMPX_FILE _PATH_UTMP
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Must be kept in sync with struct utmp as defined in sys/utmp.h! */
|
||||
struct utmpx
|
||||
{
|
||||
short ut_type;
|
||||
pid_t ut_pid;
|
||||
char ut_line[UT_LINESIZE];
|
||||
char ut_id[UT_IDLEN];
|
||||
time_t ut_time;
|
||||
char ut_user[UT_NAMESIZE];
|
||||
char ut_host[UT_HOSTSIZE];
|
||||
long ut_addr;
|
||||
struct timeval ut_tv;
|
||||
};
|
||||
|
||||
extern void endutxent (void);
|
||||
extern struct utmpx *getutxent (void);
|
||||
extern struct utmpx *getutxid (const struct utmpx *id);
|
||||
extern struct utmpx *getutxline (const struct utmpx *line);
|
||||
extern struct utmpx *pututxline (const struct utmpx *utmpx);
|
||||
extern void setutxent (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* UTMPX_H */
|
|
@ -29,6 +29,7 @@ details. */
|
|||
#include <stdio.h>
|
||||
#include <process.h>
|
||||
#include <utmp.h>
|
||||
#include <utmpx.h>
|
||||
#include <sys/uio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
@ -2559,6 +2560,17 @@ static unsigned utix = 0;
|
|||
utmp_data_buf + utix++; \
|
||||
})
|
||||
|
||||
static struct utmpx *
|
||||
copy_ut_to_utx (struct utmp *ut, struct utmpx *utx)
|
||||
{
|
||||
if (!ut)
|
||||
return NULL;
|
||||
memcpy (utx, ut, sizeof *ut);
|
||||
utx->ut_tv.tv_sec = ut->ut_time;
|
||||
utx->ut_tv.tv_usec = 0;
|
||||
return utx;
|
||||
}
|
||||
|
||||
extern "C" struct utmp *
|
||||
getutent ()
|
||||
{
|
||||
|
@ -2635,16 +2647,16 @@ getutline (struct utmp *line)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
extern "C" struct utmp *
|
||||
pututline (struct utmp *ut)
|
||||
{
|
||||
if (check_null_invalid_struct (ut))
|
||||
return;
|
||||
return NULL;
|
||||
internal_setutent (true);
|
||||
if (utmp_fd < 0)
|
||||
{
|
||||
debug_printf ("error: utmp_fd %d", utmp_fd);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
debug_printf ("ut->ut_type %d, ut->ut_pid %d, ut->ut_line '%s', ut->ut_id '%s'\n",
|
||||
ut->ut_type, ut->ut_pid, ut->ut_line, ut->ut_id);
|
||||
|
@ -2659,6 +2671,59 @@ pututline (struct utmp *ut)
|
|||
}
|
||||
else
|
||||
locked_append (utmp_fd, ut, sizeof *ut);
|
||||
return ut;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
setutxent ()
|
||||
{
|
||||
internal_setutent (false);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
endutxent ()
|
||||
{
|
||||
endutent ();
|
||||
}
|
||||
|
||||
extern "C" struct utmpx *
|
||||
getutxent ()
|
||||
{
|
||||
static struct utmpx utx;
|
||||
return copy_ut_to_utx (getutent (), &utx);
|
||||
}
|
||||
|
||||
extern "C" struct utmpx *
|
||||
getutxid (const struct utmpx *id)
|
||||
{
|
||||
static struct utmpx utx;
|
||||
|
||||
if (__check_invalid_read_ptr (id, sizeof *id))
|
||||
return NULL;
|
||||
((struct utmpx *)id)->ut_time = id->ut_tv.tv_sec;
|
||||
return copy_ut_to_utx (getutid ((struct utmp *) id), &utx);
|
||||
}
|
||||
|
||||
extern "C" struct utmpx *
|
||||
getutxline (const struct utmpx *line)
|
||||
{
|
||||
static struct utmpx utx;
|
||||
|
||||
if (__check_invalid_read_ptr (line, sizeof *line))
|
||||
return NULL;
|
||||
((struct utmpx *)line)->ut_time = line->ut_tv.tv_sec;
|
||||
return copy_ut_to_utx (getutline ((struct utmp *) line), &utx);
|
||||
}
|
||||
|
||||
extern "C" struct utmpx *
|
||||
pututxline (const struct utmpx *utmpx)
|
||||
{
|
||||
static struct utmpx utx;
|
||||
|
||||
if (__check_invalid_read_ptr (utmpx, sizeof *utmpx))
|
||||
return NULL;
|
||||
((struct utmpx *)utmpx)->ut_time = utmpx->ut_tv.tv_sec;
|
||||
return copy_ut_to_utx (pututline ((struct utmp *) utmpx), &utx);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
|
|
Loading…
Reference in New Issue