This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] S/390: Fix 31/64 bit utmp compat problem


> Yes, it shows you put a lot of quality testing into the patch.  Have you
> even reviewed it?  All the garbage you sent?

Sorry. I overhasty tried to convert it to unified diff format which
unfortunately included the quilt directory what totally garbled the
patch. Of course I reviewed the patch before.
 
> Plus: you don't modify generic code.  The only change allowed is perhaps
> something like
> 
> +#ifndef updwtmp
>  weak_alias (__updwtmp, updwtmp)
> +endif

I was just trying to mimic what has been done for the long double 128
bit stuff with the ldbl_strong_alias macro.  I don't see how that
could be achieved with less impact to the generic parts.  Could you
please elaborate?

Thanks.

Bye,

-Andreas-


Here again the patch. I've tried to do a better job converting it:

diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/Versions.def libc/Versions.def
--- libc.orig/Versions.def	2008-04-24 11:09:18.000000000 +0200
+++ libc/Versions.def	2008-04-24 08:42:34.000000000 +0200
@@ -105,6 +105,7 @@ librt {
 }
 libutil {
   GLIBC_2.0
+  GLIBC_2.8
 }
 ld {
   GLIBC_2.0
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutent.c libc/login/getutent.c
--- libc.orig/login/getutent.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutent.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <utmp.h>
 
+#include "utmp-compat.h"
 
 /* Local buffer to store the result.  */
 libc_freeres_ptr (static struct utmp *buffer);
@@ -42,4 +43,4 @@ __getutent (void)
 
   return result;
 }
-weak_alias (__getutent, getutent)
+utmp_compat_symbol (__getutent, getutent);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutent_r.c libc/login/getutent_r.c
--- libc.orig/login/getutent_r.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutent_r.c	2008-04-24 08:42:34.000000000 +0200
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <utmp.h>
 
+#include "utmp-compat.h"
 #include "utmp-private.h"
 
 
@@ -152,7 +153,7 @@ __getutent_r (struct utmp *buffer, struc
 
   return retval;
 }
-weak_alias (__getutent_r, getutent_r)
+utmp_compat_symbol (__getutent_r, getutent_r)
 
 
 struct utmp *
@@ -168,7 +169,7 @@ __pututline (const struct utmp *data)
 
   return buffer;
 }
-weak_alias (__pututline, pututline)
+utmp_compat_symbol (__pututline, pututline);
 
 
 void
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutid.c libc/login/getutid.c
--- libc.orig/login/getutid.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutid.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <utmp.h>
 
+#include "utmp-compat.h"
 
 /* Local buffer to store the result.  */
 libc_freeres_ptr (static struct utmp *buffer);
@@ -40,4 +41,5 @@ __getutid (const struct utmp *id)
 
   return result;
 }
-weak_alias (__getutid, getutid)
+
+utmp_compat_symbol (__getutid, getutid);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutid_r.c libc/login/getutid_r.c
--- libc.orig/login/getutid_r.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutid_r.c	2008-04-24 08:42:34.000000000 +0200
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <utmp.h>
 
+#include "utmp-compat.h"
 #include "utmp-private.h"
 
 
@@ -60,4 +61,4 @@ __getutid_r (const struct utmp *id, stru
   return -1;
 #endif
 }
-weak_alias (__getutid_r, getutid_r)
+utmp_compat_symbol (__getutid_r, getutid_r)
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutline.c libc/login/getutline.c
--- libc.orig/login/getutline.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutline.c	2008-04-24 09:51:13.000000000 +0200
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <utmp.h>
 
+#include "utmp-compat.h"
 
 /* Local buffer to store the result.  */
 libc_freeres_ptr (static struct utmp *buffer);
@@ -41,4 +42,4 @@ __getutline (const struct utmp *line)
 
   return result;
 }
-weak_alias (__getutline, getutline)
+utmp_compat_symbol (__getutline, getutline)
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutline_r.c libc/login/getutline_r.c
--- libc.orig/login/getutline_r.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutline_r.c	2008-04-24 08:42:34.000000000 +0200
@@ -22,6 +22,7 @@
 #include <bits/libc-lock.h>
 #include <utmp.h>
 
+#include "utmp-compat.h"
 #include "utmp-private.h"
 
 
@@ -43,4 +44,4 @@ __getutline_r (const struct utmp *line, 
 
   return retval;
 }
-weak_alias (__getutline_r, getutline_r)
+utmp_compat_symbol (__getutline_r, getutline_r)
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutmp.c libc/login/getutmp.c
--- libc.orig/login/getutmp.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutmp.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,9 +20,11 @@
 #include <utmp.h>
 #include <utmpx.h>
 
+#include "utmp-compat.h"
+
 /* Copy the information in UTMPX to UTMP. */
 void
-getutmp (const struct utmpx *utmpx, struct utmp *utmp)
+__getutmp (const struct utmpx *utmpx, struct utmp *utmp)
 {
 #if _HAVE_UT_TYPE - 0
   utmp->ut_type = utmpx->ut_type;
@@ -44,3 +46,4 @@ getutmp (const struct utmpx *utmpx, stru
   utmp->ut_time = utmpx->ut_time;
 #endif
 }
+utmp_compat_symbol (__getutmp, getutmp);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutmpx.c libc/login/getutmpx.c
--- libc.orig/login/getutmpx.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutmpx.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,9 +20,11 @@
 #include <utmp.h>
 #include <utmpx.h>
 
+#include "utmp-compat.h"
+
 /* Copy the information in UTMP to UTMPX. */
 void
-getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
+__getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
 {
   memset (utmpx, 0, sizeof (struct utmpx));
 
@@ -46,3 +48,4 @@ getutmpx (const struct utmp *utmp, struc
   utmpx->ut_time = utmp->ut_time;
 #endif
 }
+utmp_compat_symbol (__getutmpx, getutmpx);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutxent.c libc/login/getutxent.c
--- libc.orig/login/getutxent.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutxent.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,8 +20,11 @@
 #include <utmp.h>
 #include <utmpx.h>
 
+#include "utmp-compat.h"
+
 struct utmpx *
-getutxent (void)
+__getutxent (void)
 {
   return (struct utmpx *) __getutent ();
 }
+utmp_compat_symbol (__getutxent, getutxent);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutxid.c libc/login/getutxid.c
--- libc.orig/login/getutxid.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutxid.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,8 +20,11 @@
 #include <utmp.h>
 #include <utmpx.h>
 
+#include "utmp-compat.h"
+
 struct utmpx *
-getutxid (const struct utmpx *id)
+__getutxid (const struct utmpx *id)
 {
   return (struct utmpx *) __getutid ((const struct utmp *) id);
 }
+utmp_compat_symbol (__getutxid, getutxid);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/getutxline.c libc/login/getutxline.c
--- libc.orig/login/getutxline.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/getutxline.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,8 +20,11 @@
 #include <utmp.h>
 #include <utmpx.h>
 
+#include "utmp-compat.h"
+
 struct utmpx *
-getutxline (const struct utmpx *line)
+__getutxline (const struct utmpx *line)
 {
   return (struct utmpx *) __getutline ((const struct utmp *) line);
 }
+utmp_compat_symbol (__getutxline, getutxline);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/login.c libc/login/login.c
--- libc.orig/login/login.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/login.c	2008-04-24 08:42:34.000000000 +0200
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <utmp.h>
 
+#include "utmp-compat.h"
+
 
 /* Return the result of ttyname in the buffer pointed to by TTY, which should
    be of length BUF_LEN.  If it is too long to fit in this buffer, a
@@ -79,7 +81,7 @@ tty_name (int fd, char **tty, size_t buf
 }
 
 void
-login (const struct utmp *ut)
+__login (const struct utmp *ut)
 {
 #ifdef PATH_MAX
   char _tty[PATH_MAX + UT_LINESIZE];
@@ -142,3 +144,4 @@ login (const struct utmp *ut)
   /* Update the WTMP file.  Here we have to add a new entry.  */
   updwtmp (_PATH_WTMP, &copy);
 }
+utmp_compat_symbol (__login, login);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/pututxline.c libc/login/pututxline.c
--- libc.orig/login/pututxline.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/pututxline.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,8 +20,11 @@
 #include <utmp.h>
 #include <utmpx.h>
 
+#include "utmp-compat.h"
+
 struct utmpx *
-pututxline (const struct utmpx *utmpx)
+__pututxline (const struct utmpx *utmpx)
 {
   return (struct utmpx *) __pututline ((const struct utmp *) utmpx);
 }
+utmp_compat_symbol (__pututxline, pututxline);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/updwtmp.c libc/login/updwtmp.c
--- libc.orig/login/updwtmp.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/updwtmp.c	2008-04-24 08:42:34.000000000 +0200
@@ -19,6 +19,7 @@
 
 #include <utmp.h>
 
+#include "utmp-compat.h"
 #include "utmp-private.h"
 
 #ifndef TRANSFORM_UTMP_FILE_NAME
@@ -32,4 +33,4 @@ __updwtmp (const char *wtmp_file, const 
 
   (*__libc_utmp_file_functions.updwtmp) (file_name, utmp);
 }
-weak_alias (__updwtmp, updwtmp)
+utmp_compat_symbol (__updwtmp, updwtmp);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/updwtmpx.c libc/login/updwtmpx.c
--- libc.orig/login/updwtmpx.c	2008-04-24 11:09:18.000000000 +0200
+++ libc/login/updwtmpx.c	2008-04-24 08:42:34.000000000 +0200
@@ -20,8 +20,11 @@
 #include <utmp.h>
 #include <utmpx.h>
 
+#include "utmp-compat.h"
+
 void
-updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx)
+__updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx)
 {
   __updwtmp (wtmpx_file, (const struct utmp *) utmpx);
 }
+utmp_compat_symbol (__updwtmpx, updwtmpx);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/login/utmp-compat.h libc/login/utmp-compat.h
--- libc.orig/login/utmp-compat.h	1970-01-01 01:00:00.000000000 +0100
+++ libc/login/utmp-compat.h	2008-04-24 12:52:59.000000000 +0200
@@ -0,0 +1,30 @@
+/* Copyright (C) 2008 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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.  */
+
+#include <bits/wordsize.h>
+#include <libc-symbols.h>
+
+/* __UTMP_COMPAT_BASE contains the version tag of the glibc version at
+   which the utmp 64 bit compat functions were added.  */
+#ifdef __UTMP_COMPAT_BASE
+# define utmp_compat_symbol(name, alias)			\
+   default_symbol_version (name, alias, __UTMP_COMPAT_BASE);
+#else
+# define utmp_compat_symbol(name, alias) weak_alias (name, alias)
+#endif
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/s390/s390-32/bits/wordsize.h libc/sysdeps/s390/s390-32/bits/wordsize.h
--- libc.orig/sysdeps/s390/s390-32/bits/wordsize.h	2008-04-24 11:09:18.000000000 +0200
+++ libc/sysdeps/s390/s390-32/bits/wordsize.h	2008-04-24 08:42:34.000000000 +0200
@@ -2,6 +2,7 @@
 
 #if defined __s390x__
 # define __WORDSIZE	64
+# define __WORDSIZE_COMPAT32	1
 #else
 # define __WORDSIZE	32
 #endif
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/s390/s390-64/bits/wordsize.h libc/sysdeps/s390/s390-64/bits/wordsize.h
--- libc.orig/sysdeps/s390/s390-64/bits/wordsize.h	2008-04-24 11:09:18.000000000 +0200
+++ libc/sysdeps/s390/s390-64/bits/wordsize.h	2008-04-24 08:42:34.000000000 +0200
@@ -2,6 +2,7 @@
 
 #if defined __s390x__
 # define __WORDSIZE	64
+# define __WORDSIZE_COMPAT32	1
 #else
 # define __WORDSIZE	32
 #endif
@@ -16,3 +17,5 @@
 #  define __NO_LONG_DOUBLE_MATH        1
 # endif
 #endif
+
+#define __UTMP_COMPAT_BASE GLIBC_2.8
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/Makefile libc/sysdeps/unix/sysv/linux/s390/s390-64/Makefile
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/Makefile	2008-04-24 11:09:18.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/Makefile	2008-04-24 08:42:34.000000000 +0200
@@ -1,3 +1,8 @@
+ifeq ($(subdir),login)
+sysdep_routines += utmp64 utmpx64
+libutil-routines += login64
+endif
+
 ifeq ($(subdir),misc)
 sysdep_headers += sys/elf.h
 endif
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/Versions libc/sysdeps/unix/sysv/linux/s390/s390-64/Versions
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/Versions	2008-04-24 11:09:18.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/Versions	2008-04-24 08:42:34.000000000 +0200
@@ -4,4 +4,28 @@ libc {
     __register_frame; __register_frame_table; __deregister_frame;
     __frame_state_for; __register_frame_info_table;
   }
-}
+  GLIBC_2.8 {
+    updwtmp;
+    getutent;
+    getutid;
+    getutline;
+    pututline;
+    updwtmp;
+    getutent_r;
+    getutid_r;
+    getutline_r;
+    getutxent;
+    getutxid;
+    getutxline;
+    pututxline;
+    updwtmpx;
+    getutmp;
+    getutmpx;
+  }
+};
+
+libutil {
+  GLIBC_2.8 {
+    login;
+  }
+};
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/login64.c libc/sysdeps/unix/sysv/linux/s390/s390-64/login64.c
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/login64.c	1970-01-01 01:00:00.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/login64.c	2008-04-24 12:48:24.000000000 +0200
@@ -0,0 +1,37 @@
+/* Copyright (C) 2008 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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.  */
+
+#include <sys/types.h>
+#include <utmp.h>
+#include <libc-symbols.h>
+
+#include "utmp64.h"
+#include "utmp-convert.h"
+
+/* Write the given entry into utmp and wtmp.  */
+void
+__login64 (__const struct utmp64 *__entry)
+{
+  const struct utmp tmp32;
+
+  __utmp_convert64to32 (__entry, &tmp32);
+  login (&tmp32);
+}
+
+symbol_version (__login64, login, GLIBC_2.2);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmp-convert.h libc/sysdeps/unix/sysv/linux/s390/s390-64/utmp-convert.h
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmp-convert.h	1970-01-01 01:00:00.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/utmp-convert.h	2008-04-24 12:51:16.000000000 +0200
@@ -0,0 +1,83 @@
+/* Copyright (C) 2008 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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.  */
+
+
+/* This file provides functions converting between the 31 and 64 bit
+   struct utmp variants.  */
+
+#ifndef _UTMP_CONVERT_H
+#define _UTMP_CONVERT_H 1
+
+#include <string.h>
+
+#include "utmp64.h"
+
+static inline void
+__utmp_convert32to64 (const struct utmp *from, struct utmp64 *to)
+{
+#if _HAVE_UT_TYPE - 0
+  to->ut_type = from->ut_type;
+#endif
+#if _HAVE_UT_PID - 0
+  to->ut_pid = from->ut_pid;
+#endif
+  memcpy (to->ut_line, from->ut_line, UT_LINESIZE);
+  memcpy (to->ut_user, from->ut_user, UT_NAMESIZE);
+#if _HAVE_UT_ID - 0
+  memcpy (to->ut_id, from->ut_id, 4);
+#endif
+#if _HAVE_UT_HOST - 0
+  memcpy (to->ut_host, from->ut_host, UT_HOSTSIZE);
+#endif
+  to->ut_exit = from->ut_exit;
+  to->ut_session = (int64_t)from->ut_session;
+#if _HAVE_UT_TV - 0
+  to->ut_tv.tv_sec = (int64_t)from->ut_tv.tv_sec;
+  to->ut_tv.tv_usec = (int64_t)from->ut_tv.tv_usec;
+#endif
+  memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4);
+}
+
+static inline void
+__utmp_convert64to32 (const struct utmp64 *from, struct utmp *to)
+{
+#if _HAVE_UT_TYPE - 0
+  to->ut_type = from->ut_type;
+#endif
+#if _HAVE_UT_PID - 0
+  to->ut_pid = from->ut_pid;
+#endif
+  memcpy (to->ut_line, from->ut_line, UT_LINESIZE);
+  memcpy (to->ut_user, from->ut_user, UT_NAMESIZE);
+#if _HAVE_UT_ID - 0
+  memcpy (to->ut_id, from->ut_id, 4);
+#endif
+#if _HAVE_UT_HOST - 0
+  memcpy (to->ut_host, from->ut_host, UT_HOSTSIZE);
+#endif
+  to->ut_exit = from->ut_exit;
+  to->ut_session = (int32_t)from->ut_session;
+#if _HAVE_UT_TV - 0
+  to->ut_tv.tv_sec = (int32_t)from->ut_tv.tv_sec;
+  to->ut_tv.tv_usec = (int32_t)from->ut_tv.tv_usec;
+#endif
+  memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4);
+}
+
+#endif /* utmp-convert.h */
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmp64.c libc/sysdeps/unix/sysv/linux/s390/s390-64/utmp64.c
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmp64.c	1970-01-01 01:00:00.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/utmp64.c	2008-04-24 12:49:00.000000000 +0200
@@ -0,0 +1,183 @@
+/* Copyright (C) 2008 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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.  */
+
+#include <sys/types.h>
+#include <utmp.h>
+#include <errno.h>
+#include <libc-symbols.h>
+
+#include "utmp64.h"
+#include "utmp-convert.h"
+
+/* Allocate a static buffer to be returned to the caller.  As well as
+   with the existing version of these functions the caller has to be
+   aware that the contents of this buffer will change with subsequent
+   calls.  */
+#define ALLOCATE_UTMP64_OUT(OUT)			\
+  static struct utmp64 *OUT = NULL;			\
+  							\
+  if (OUT == NULL)					\
+    {							\
+      OUT = malloc (sizeof (struct utmp64));		\
+      if (OUT == NULL)					\
+	{						\
+	  __set_errno (ENOMEM);				\
+	  return NULL;					\
+	}						\
+    }
+
+#define ACCESS_UTMP_ENTRY(FUNC, FIELD)			\
+  struct utmp in32;					\
+  struct utmp *out32;					\
+  ALLOCATE_UTMP64_OUT (out64);				\
+							\
+  __utmp_convert64to32 (FIELD, &in32);			\
+  out32 = FUNC (&in32);					\
+							\
+  if (out32 == NULL)					\
+    return NULL;					\
+							\
+  __utmp_convert32to64 (out32, out64);			\
+							\
+  return out64;
+
+/* Search forward from the current point in the utmp file until the
+   next entry with a ut_type matching ID->ut_type.  */
+struct utmp64 *
+__getutid64 (__const struct utmp64 *__id)
+{
+  ACCESS_UTMP_ENTRY (getutid, __id)
+}
+
+/* Search forward from the current point in the utmp file until the
+   next entry with a ut_line matching LINE->ut_line.  */
+struct utmp64 *
+__getutline64 (__const struct utmp64 *__line)
+{
+  ACCESS_UTMP_ENTRY (getutline, __line)
+}
+
+/* Write out entry pointed to by UTMP_PTR into the utmp file.  */
+struct utmp64 *
+__pututline64 (__const struct utmp64 *__utmp_ptr)
+{
+  ACCESS_UTMP_ENTRY (pututline, __utmp_ptr)
+}
+
+/* Read next entry from a utmp-like file.  */
+struct utmp64 *
+__getutent64 ()
+{
+  struct utmp *out32;
+  ALLOCATE_UTMP64_OUT (out64);
+
+  out32 = getutent ();
+  if (!out32)
+    return NULL;
+
+  __utmp_convert32to64 (out32, out64);
+  return out64;
+}
+
+
+/* Reentrant versions of the file for handling utmp files.  */
+
+int
+__getutent_r64 (struct utmp64 *__buffer, struct utmp64 **__result)
+{
+  struct utmp out32, *out32p;
+  int ret;
+
+  ret = getutent_r (&out32, &out32p);
+  if (ret == -1)
+    {
+      *__result = NULL;
+      return -1;
+    }
+
+  __utmp_convert32to64 (out32p, __buffer);
+  *__result = __buffer;
+
+  return 0;
+}
+
+int
+__getutid_r64 (__const struct utmp64 *__id, struct utmp64 *__buffer,
+	       struct utmp64 **__result)
+{
+  struct utmp in32, out32, *out32p;
+  int ret;
+
+  __utmp_convert64to32 (__id, &in32);
+
+  ret = getutid_r (&in32, &out32, &out32p);
+  if (ret == -1)
+    {
+      *__result = NULL;
+      return -1;
+    }
+
+  __utmp_convert32to64 (out32p, __buffer);
+  *__result = __buffer;
+
+  return 0;
+}
+
+int __getutline_r64 (__const struct utmp64 *__line,
+		     struct utmp64 *__buffer, struct utmp64 **__result)
+{
+  struct utmp in32, out32, *out32p;
+  int ret;
+
+  __utmp_convert32to64 (__line, &in32);
+
+  ret = getutline_r (&in32, &out32, &out32p);
+  if (ret == -1)
+    {
+      *__result = NULL;
+      return -1;
+    }
+
+  __utmp_convert64to32 (out32p, __buffer);
+  *__result = __buffer;
+
+  return 0;
+
+}
+
+/* Append entry UTMP to the wtmp-like file WTMP_FILE.  */
+void
+__updwtmp64 (__const char *__wtmp_file, __const struct utmp64 *__utmp)
+{
+  const struct utmp tmp32;
+
+  __utmp_convert64to32 (__utmp, &tmp32);
+  updwtmp (__wtmp_file, &tmp32);
+}
+
+symbol_version (__getutent64, getutent, GLIBC_2.2);
+symbol_version (__getutid64, getutid, GLIBC_2.2);
+symbol_version (__getutline64, getutline, GLIBC_2.2);
+symbol_version (__pututline64, pututline, GLIBC_2.2);
+
+symbol_version (__getutent_r64, getutent_r, GLIBC_2.2);
+symbol_version (__getutid_r64, getutid_r, GLIBC_2.2);
+symbol_version (__getutline_r64, getutline_r, GLIBC_2.2);
+
+symbol_version (__updwtmp64, updwtmp, GLIBC_2.2);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmp64.h libc/sysdeps/unix/sysv/linux/s390/s390-64/utmp64.h
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmp64.h	1970-01-01 01:00:00.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/utmp64.h	2008-04-24 12:47:55.000000000 +0200
@@ -0,0 +1,62 @@
+/* The `struct utmp' type, describing entries in the utmp file.  GNU version.
+   Copyright (C) 1993, 1996, 1997, 1998, 1999, 2002, 2008
+   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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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.  */
+
+#ifndef _UTMP64_H
+#define _UTMP64_H 1
+
+#include <paths.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <bits/wordsize.h>
+#include <utmp.h>
+
+/* The structure describing an entry in the database of
+   previous logins.  */
+struct lastlog64
+  {
+    int64_t ll_time;
+    char ll_line[UT_LINESIZE];
+    char ll_host[UT_HOSTSIZE];
+  };
+
+/* The structure describing an entry in the user accounting database.  */
+struct utmp64
+{
+  short int ut_type;		/* Type of login.  */
+  pid_t ut_pid;			/* Process ID of login process.  */
+  char ut_line[UT_LINESIZE];	/* Devicename.  */
+  char ut_id[4];		/* Inittab ID.  */
+  char ut_user[UT_NAMESIZE];	/* Username.  */
+  char ut_host[UT_HOSTSIZE];	/* Hostname for remote login.  */
+  struct exit_status ut_exit;	/* Exit status of a process marked
+				   as DEAD_PROCESS.  */
+  int64_t ut_session;		/* Session ID, used for windowing.  */
+  struct
+  {
+    int64_t tv_sec;		/* Seconds.  */
+    int64_t tv_usec;		/* Microseconds.  */
+  } ut_tv;			/* Time entry was made.  */
+
+  int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
+  char __unused[20];		/* Reserved for future use.  */
+};
+
+
+#endif  /* utmp64.h  */
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmpx-convert.h libc/sysdeps/unix/sysv/linux/s390/s390-64/utmpx-convert.h
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmpx-convert.h	1970-01-01 01:00:00.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/utmpx-convert.h	2008-04-24 12:51:20.000000000 +0200
@@ -0,0 +1,82 @@
+/* Copyright (C) 2008 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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.  */
+
+
+/* This file provides functions converting between the 31 and 64 bit
+   struct utmp variants.  */
+
+#ifndef _UTMPX_CONVERT_H
+#define _UTMPX_CONVERT_H 1
+
+#include <string.h>
+#include "utmpx64.h"
+
+static inline void
+__utmpx_convert32to64 (const struct utmpx *from, struct utmpx64 *to)
+{
+#if _HAVE_UT_TYPE - 0
+  to->ut_type = from->ut_type;
+#endif
+#if _HAVE_UT_PID - 0
+  to->ut_pid = from->ut_pid;
+#endif
+  memcpy (to->ut_line, from->ut_line, __UT_LINESIZE);
+  memcpy (to->ut_user, from->ut_user, __UT_NAMESIZE);
+#if _HAVE_UT_ID - 0
+  memcpy (to->ut_id, from->ut_id, 4);
+#endif
+#if _HAVE_UT_HOST - 0
+  memcpy (to->ut_host, from->ut_host, __UT_HOSTSIZE);
+#endif
+  to->ut_exit = from->ut_exit;
+  to->ut_session = (int64_t)from->ut_session;
+#if _HAVE_UT_TV - 0
+  to->ut_tv.tv_sec = (int64_t)from->ut_tv.tv_sec;
+  to->ut_tv.tv_usec = (int64_t)from->ut_tv.tv_usec;
+#endif
+  memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4);
+}
+
+static inline void
+__utmpx_convert64to32 (const struct utmpx64 *from, struct utmpx *to)
+{
+#if _HAVE_UT_TYPE - 0
+  to->ut_type = from->ut_type;
+#endif
+#if _HAVE_UT_PID - 0
+  to->ut_pid = from->ut_pid;
+#endif
+  memcpy (to->ut_line, from->ut_line, __UT_LINESIZE);
+  memcpy (to->ut_user, from->ut_user, __UT_NAMESIZE);
+#if _HAVE_UT_ID - 0
+  memcpy (to->ut_id, from->ut_id, 4);
+#endif
+#if _HAVE_UT_HOST - 0
+  memcpy (to->ut_host, from->ut_host, __UT_HOSTSIZE);
+#endif
+  to->ut_exit = from->ut_exit;
+  to->ut_session = (int32_t)from->ut_session;
+#if _HAVE_UT_TV - 0
+  to->ut_tv.tv_sec = (int32_t)from->ut_tv.tv_sec;
+  to->ut_tv.tv_usec = (int32_t)from->ut_tv.tv_usec;
+#endif
+  memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4);
+}
+
+#endif /* utmpx-convert.h */
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmpx64.c libc/sysdeps/unix/sysv/linux/s390/s390-64/utmpx64.c
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmpx64.c	1970-01-01 01:00:00.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/utmpx64.c	2008-04-24 12:48:38.000000000 +0200
@@ -0,0 +1,171 @@
+/* Copyright (C) 2008 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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.  */
+
+#include <sys/types.h>
+#include <utmp.h>
+#include <errno.h>
+#include <libc-symbols.h>
+
+#include "utmp64.h"
+#include "utmp-convert.h"
+
+#include "utmpx64.h"
+#include "utmpx-convert.h"
+
+/* Allocate a static buffer to be returned to the caller.  As well as
+   with the existing version of these functions the caller has to be
+   aware that the contents of this buffer will change with subsequent
+   calls.  */
+#define ALLOCATE_UTMPX64_OUT(OUT)			\
+  static struct utmpx64 *OUT = NULL;			\
+  							\
+  if (OUT == NULL)					\
+    {							\
+      OUT = malloc (sizeof (struct utmpx64));		\
+      if (OUT == NULL)					\
+	{						\
+	  __set_errno (ENOMEM);				\
+	  return NULL;					\
+	}						\
+    }
+
+#define ACCESS_UTMPX_ENTRY(FUNC, FIELD)			\
+  struct utmpx in32;					\
+  struct utmpx *out32;					\
+  ALLOCATE_UTMPX64_OUT (out64);				\
+							\
+  __utmpx_convert64to32 (FIELD, &in32);			\
+  out32 = FUNC (&in32);					\
+							\
+  if (out32 == NULL)					\
+    return NULL;					\
+							\
+  __utmpx_convert32to64 (out32, out64);			\
+							\
+  return out64;
+
+
+/* Get the next entry from the user accounting database.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+struct utmpx64 *
+__getutxent64 ()
+{
+  struct utmpx *out32;
+  ALLOCATE_UTMPX64_OUT (out64);
+
+  out32 = getutxent ();
+  if (!out32)
+    return NULL;
+
+  __utmpx_convert32to64 (out32, out64);
+  return out64;
+
+}
+
+/* Get the user accounting database entry corresponding to ID.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+struct utmpx64 *
+__getutxid64 (__const struct utmpx64 *__id)
+{
+  ACCESS_UTMPX_ENTRY (getutxid, __id);
+}
+
+/* Get the user accounting database entry corresponding to LINE.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+struct utmpx64 *
+__getutxline64 (__const struct utmpx64 *__line)
+{
+  ACCESS_UTMPX_ENTRY (getutxline, __line);
+}
+
+/* Write the entry UTMPX into the user accounting database.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+struct utmpx64 *
+__pututxline64 (__const struct utmpx64 *__utmpx)
+{
+  ACCESS_UTMPX_ENTRY (pututxline, __utmpx);
+}
+
+/* Append entry UTMP to the wtmpx-like file WTMPX_FILE.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+void
+__updwtmpx64 (__const char *__wtmpx_file, __const struct utmpx64 *__utmpx)
+{
+  struct utmpx in32;
+
+  __utmpx_convert64to32 (__utmpx, &in32);
+  updwtmpx (__wtmpx_file, &in32);
+}
+
+
+/* Copy the information in UTMPX to UTMP.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+void
+__getutmp64 (__const struct utmpx64 *__utmpx, struct utmp64 *__utmp)
+{
+  struct utmpx in32;
+  struct utmp out32;
+
+  __utmpx_convert64to32 (__utmpx, &in32);
+  getutmp (&in32, &out32);
+  __utmp_convert32to64 (&out32, __utmp);
+}
+
+/* Copy the information in UTMP to UTMPX.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+void
+__getutmpx64 (__const struct utmp64 *__utmp, struct utmpx64 *__utmpx)
+{
+  struct utmp in32;
+  struct utmpx out32;
+
+  __utmp_convert64to32 (__utmp, &in32);
+  getutmpx (&in32, &out32);
+  __utmpx_convert32to64 (&out32, __utmpx);
+}
+
+symbol_version (__getutxent64, getutxent, GLIBC_2.2);
+symbol_version (__getutxid64, getutxid, GLIBC_2.2);
+symbol_version (__getutxline64, getutxline, GLIBC_2.2);
+symbol_version (__pututxline64, pututxline, GLIBC_2.2);
+
+symbol_version (__updwtmpx64, updwtmpx, GLIBC_2.2);
+
+symbol_version (__getutmp64, getutmp, GLIBC_2.2);
+symbol_version (__getutmpx64, getutmpx, GLIBC_2.2);
diff -N -p -U3 --exclude=.pc --exclude=patches -r libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmpx64.h libc/sysdeps/unix/sysv/linux/s390/s390-64/utmpx64.h
--- libc.orig/sysdeps/unix/sysv/linux/s390/s390-64/utmpx64.h	1970-01-01 01:00:00.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/utmpx64.h	2008-04-24 12:47:31.000000000 +0200
@@ -0,0 +1,52 @@
+/* The `struct utmpx' type, describing entries in the utmp file.  GNU version.
+   Copyright (C) 1993, 1996, 1997, 1998, 1999, 2002, 2008
+   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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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.  */
+
+#ifndef _UTMPX64_H
+#define _UTMPX64_H 1
+
+#include <paths.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <bits/wordsize.h>
+#include <utmpx.h>
+
+/* The structure describing an entry in the user accounting database.  */
+struct utmpx64
+{
+  short int ut_type;		/* Type of login.  */
+  __pid_t ut_pid;		/* Process ID of login process.  */
+  char ut_line[__UT_LINESIZE];	/* Devicename.  */
+  char ut_id[4];		/* Inittab ID. */
+  char ut_user[__UT_NAMESIZE];	/* Username.  */
+  char ut_host[__UT_HOSTSIZE];	/* Hostname for remote login.  */
+  struct __exit_status ut_exit;	/* Exit status of a process marked
+				   as DEAD_PROCESS.  */
+  __int64_t ut_session;		/* Session ID, used for windowing.  */
+  struct
+  {
+    __int64_t tv_sec;		/* Seconds.  */
+    __int64_t tv_usec;		/* Microseconds.  */
+  } ut_tv;			/* Time entry was made.  */
+
+  __int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
+  char __unused[20];		/* Reserved for future use.  */
+};
+
+#endif /* utmpx64.h */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]