Hi,
I worked on 2 test cases for foogid16 system calls; and I will do 5 more.
All these test cases have the same macro. So I'd like to introduce compat_gid.h;
and put the macro to the file.
Could you add compat_gid.h to testcases/kernel/syscalls/utils/ and apply patches
for existing test cases?
Here after I'd like to use the compat_gid.h in newly ported test cases.
Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]>
/*
*
* Copyright (c) Red Hat Inc., 2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Author: Masatake YAMATO <[EMAIL PROTECTED]> */
#ifndef __COMPAT_GID_16_H__
#define __COMPAT_GID_16_H__
#include <asm/posix_types.h>
#ifdef TST_USE_COMPAT16_SYSCALL
typedef __kernel_old_gid_t GID_T;
int
GID_SIZE_CHECK(gid_t gid)
{
/* See high2lowgid in linux/highuid.h
Return 0 if gid is too large to store
it to __kernel_old_gid_t. */
return ((gid) & ~0xFFFF)? 0: 1;
}
#else
typedef gid_t GID_T;
int
GID_SIZE_CHECK(gid_t gid)
{
return 1;
}
#endif
#endif /* __SETGID_COMPAT_16_H__ */
Index: testcases/kernel/syscalls/setgid/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgid/Makefile,v
retrieving revision 1.11
diff -c -r1.11 Makefile
*** testcases/kernel/syscalls/setgid/Makefile 25 Aug 2008 14:10:02 -0000
1.11
--- testcases/kernel/syscalls/setgid/Makefile 9 Sep 2008 08:12:09 -0000
***************
*** 16,22 ****
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
! CFLAGS += -I../../../../include -Wall
LDLIBS += -L../../../../lib -lltp
include ../utils/compat_16.mk
--- 16,22 ----
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
! CFLAGS += -I../../../../include -I../utils -Wall
LDLIBS += -L../../../../lib -lltp
include ../utils/compat_16.mk
Index: testcases/kernel/syscalls/setgid/compat_16.h
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgid/compat_16.h,v
retrieving revision 1.2
diff -c -r1.2 compat_16.h
*** testcases/kernel/syscalls/setgid/compat_16.h 19 Aug 2008 07:00:50
-0000 1.2
--- testcases/kernel/syscalls/setgid/compat_16.h 9 Sep 2008 08:12:09
-0000
***************
*** 23,77 ****
#define __SETGID_COMPAT_16_H__
- #include <asm/posix_types.h>
#include "linux_syscall_numbers.h"
#ifdef TST_USE_COMPAT16_SYSCALL
! typedef __kernel_old_gid_t GID_T;
! int
! COMPAT_SIZE_CHECK(gid_t gid)
! {
! /* See high2lowgid in linux/highuid.h
! Return 0 if gid is too large to store
! it to __kernel_old_gid_t. */
! return ((gid) & ~0xFFFF)? 0: 1;
! }
int
SETGID(GID_T gid)
{
return syscall(__NR_setgid, gid);
}
GID_T
GETGID(void)
{
gid_t gid;
gid = getgid();
! if (!COMPAT_SIZE_CHECK(gid))
tst_brkm(TBROK,
cleanup,
"gid for the current process is too large for testing
setgid16");
return (GID_T)gid;
}
#else
! typedef gid_t GID_T;
! int
! COMPAT_SIZE_CHECK(gid_t gid)
! {
! return 1;
! }
int
SETGID(GID_T gid)
{
return setgid(gid);
}
GID_T
GETGID(void)
{
return getgid();
}
#endif
#endif /* __SETGID_COMPAT_16_H__ */
--- 23,68 ----
#define __SETGID_COMPAT_16_H__
#include "linux_syscall_numbers.h"
+ #include "compat_gid.h"
#ifdef TST_USE_COMPAT16_SYSCALL
!
int
SETGID(GID_T gid)
{
return syscall(__NR_setgid, gid);
}
+
GID_T
GETGID(void)
{
gid_t gid;
gid = getgid();
! if (!GID_SIZE_CHECK(gid))
tst_brkm(TBROK,
cleanup,
"gid for the current process is too large for testing
setgid16");
return (GID_T)gid;
}
+
#else
!
int
SETGID(GID_T gid)
{
return setgid(gid);
}
+
GID_T
GETGID(void)
{
return getgid();
}
+
#endif
#endif /* __SETGID_COMPAT_16_H__ */
Index: testcases/kernel/syscalls/setgid/setgid02.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgid/setgid02.c,v
retrieving revision 1.6
diff -c -r1.6 setgid02.c
*** testcases/kernel/syscalls/setgid/setgid02.c 20 Aug 2008 10:55:21 -0000
1.6
--- testcases/kernel/syscalls/setgid/setgid02.c 9 Sep 2008 08:12:09 -0000
***************
*** 93,99 ****
"%s", root);
}
! if (!COMPAT_SIZE_CHECK(rootpwent->pw_gid)) {
tst_brkm(TBROK,
cleanup,
"gid for `%s' is too large for testing setgid16",
--- 93,99 ----
"%s", root);
}
! if (!GID_SIZE_CHECK(rootpwent->pw_gid)) {
tst_brkm(TBROK,
cleanup,
"gid for `%s' is too large for testing setgid16",
***************
*** 134,140 ****
}
ltpuser = getpwnam(nobody_uid);
! if (!COMPAT_SIZE_CHECK(ltpuser->pw_gid)) {
tst_brkm(TBROK,
cleanup,
"gid for `%s' is too large for testing setgid16",
--- 134,140 ----
}
ltpuser = getpwnam(nobody_uid);
! if (!GID_SIZE_CHECK(ltpuser->pw_gid)) {
tst_brkm(TBROK,
cleanup,
"gid for `%s' is too large for testing setgid16",
Index: testcases/kernel/syscalls/setgid/setgid03.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgid/setgid03.c,v
retrieving revision 1.5
diff -c -r1.5 setgid03.c
*** testcases/kernel/syscalls/setgid/setgid03.c 20 Aug 2008 10:55:21 -0000
1.5
--- testcases/kernel/syscalls/setgid/setgid03.c 9 Sep 2008 08:12:09 -0000
***************
*** 138,144 ****
"id %s", ltpuser1);
}
! if (!(COMPAT_SIZE_CHECK(rootpwent->pw_gid))) {
tst_brkm(TBROK,
cleanup,
"gid for `%s' is too large for testing setgid16",
--- 138,144 ----
"id %s", ltpuser1);
}
! if (!(GID_SIZE_CHECK(rootpwent->pw_gid))) {
tst_brkm(TBROK,
cleanup,
"gid for `%s' is too large for testing setgid16",
Index: testcases/kernel/syscalls/setgroups/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/Makefile,v
retrieving revision 1.8
diff -c -r1.8 Makefile
*** testcases/kernel/syscalls/setgroups/Makefile 27 Aug 2008 12:02:42
-0000 1.8
--- testcases/kernel/syscalls/setgroups/Makefile 9 Sep 2008 08:12:09
-0000
***************
*** 16,22 ****
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
! CFLAGS += -I../../../../include -Wall
LDLIBS += -L../../../../lib -lltp
include ../utils/compat_16.mk
--- 16,22 ----
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
! CFLAGS += -I../../../../include -I../utils -Wall
LDLIBS += -L../../../../lib -lltp
include ../utils/compat_16.mk
Index: testcases/kernel/syscalls/setgroups/compat_16.h
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/compat_16.h,v
retrieving revision 1.1
diff -c -r1.1 compat_16.h
*** testcases/kernel/syscalls/setgroups/compat_16.h 27 Aug 2008 12:02:42
-0000 1.1
--- testcases/kernel/syscalls/setgroups/compat_16.h 9 Sep 2008 08:12:09
-0000
***************
*** 22,44 ****
#ifndef __SETGROUPS_COMPAT_16_H__
#define __SETGROUPS_COMPAT_16_H__
! #include <asm/posix_types.h>
#include "linux_syscall_numbers.h"
/* For avoiding circular dependency. */
extern void cleanup(void);
#ifdef TST_USE_COMPAT16_SYSCALL
- typedef __kernel_old_gid_t GID_T;
-
- int
- COMPAT_SIZE_CHECK(gid_t gid)
- {
- /* See high2lowgid in linux/highuid.h
- Return 0 if gid is too large to store
- it to __kernel_old_gid_t. */
- return ((gid) & ~0xFFFF)? 0: 1;
- }
long
SETGROUPS(int gidsetsize, GID_T *list)
--- 22,35 ----
#ifndef __SETGROUPS_COMPAT_16_H__
#define __SETGROUPS_COMPAT_16_H__
! #include "compat_gid.h"
#include "linux_syscall_numbers.h"
+
/* For avoiding circular dependency. */
extern void cleanup(void);
#ifdef TST_USE_COMPAT16_SYSCALL
long
SETGROUPS(int gidsetsize, GID_T *list)
***************
*** 64,70 ****
goto out;
for (i = 0; i < size16; i++) {
! if (!COMPAT_SIZE_CHECK(list32[i]))
tst_brkm(TBROK,
cleanup,
"gid returned from getgroups is too large for
testing setgroups32");
--- 55,61 ----
goto out;
for (i = 0; i < size16; i++) {
! if (!GID_SIZE_CHECK(list32[i]))
tst_brkm(TBROK,
cleanup,
"gid returned from getgroups is too large for
testing setgroups32");
***************
*** 77,84 ****
}
#else
- typedef gid_t GID_T;
-
int
SETGROUPS(size_t size, const GID_T *list)
{
--- 68,73 ----
***************
*** 91,101 ****
return getgroups(size, list);
}
- int
- COMPAT_SIZE_CHECK(gid_t gid)
- {
- return 1;
- }
#endif /* TST_USE_COMPAT16_SYSCALL */
#endif /* __SETGROUPS_COMPAT_16_H__ */
--- 80,85 ----
Index: testcases/kernel/syscalls/setgroups/setgroups02.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/setgroups02.c,v
retrieving revision 1.5
diff -c -r1.5 setgroups02.c
*** testcases/kernel/syscalls/setgroups/setgroups02.c 27 Aug 2008 12:02:42
-0000 1.5
--- testcases/kernel/syscalls/setgroups/setgroups02.c 9 Sep 2008 08:12:09
-0000
***************
*** 187,193 ****
tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed", TESTUSER);
}
! if (!COMPAT_SIZE_CHECK(user_info->pw_gid)) {
tst_brkm(TBROK,
cleanup,
"gid returned from getpwnam is too large for testing
setgroups16");
--- 187,193 ----
tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed", TESTUSER);
}
! if (!GID_SIZE_CHECK(user_info->pw_gid)) {
tst_brkm(TBROK,
cleanup,
"gid returned from getpwnam is too large for testing
setgroups16");
Index: testcases/kernel/syscalls/setgroups/setgroups03.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/setgroups03.c,v
retrieving revision 1.10
diff -c -r1.10 setgroups03.c
*** testcases/kernel/syscalls/setgroups/setgroups03.c 27 Aug 2008 12:02:42
-0000 1.10
--- testcases/kernel/syscalls/setgroups/setgroups03.c 9 Sep 2008 08:12:09
-0000
***************
*** 232,238 ****
tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed", TESTUSER);
}
! if (!COMPAT_SIZE_CHECK(user_info->pw_gid)) {
tst_brkm(TBROK,
cleanup,
"gid returned from getpwnam is too large for testing
setgroups16");
--- 232,238 ----
tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed", TESTUSER);
}
! if (!GID_SIZE_CHECK(user_info->pw_gid)) {
tst_brkm(TBROK,
cleanup,
"gid returned from getpwnam is too large for testing
setgroups16");
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list