PERFORCE change 181145 for review
Gabor Kovesdan
gabor at FreeBSD.org
Sun Jul 18 16:47:28 UTC 2010
http://p4web.freebsd.org/@@181145?ac=10
Change 181145 by gabor at gabor_aspire on 2010/07/18 16:47:21
- Make syscalls actually work
- Add freebsd32 compat definitions
- Cleanup
- Add some test cases
Affected files ...
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/freebsd32_proto.h#2 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/freebsd32_syscall.h#2 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/freebsd32_syscalls.c#2 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/freebsd32_sysent.c#2 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/syscalls.master#2 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/conf/files#3 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/kern/kern_fork.c#3 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/kern/kern_jobs.c#4 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/kern/syscalls.master#3 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/kern/systrace_args.c#3 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/_types.h#4 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/resource.h#3 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/sysproto.h#3 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/types.h#3 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/ucred.h#3 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/tools/test/irix_jobs/Makefile#2 edit
.. //depot/projects/soc2010/gabor_jobs/irix_jobs/tools/test/irix_jobs/jobtest.c#2 edit
Differences ...
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/freebsd32_proto.h#2 (text+ko) ====
@@ -2,8 +2,8 @@
* System call prototypes.
*
* DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD: src/sys/compat/freebsd32/freebsd32_proto.h,v 1.116 2010/06/28 18:17:21 kib Exp $
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 209579 2010-06-28 18:06:46Z kib
+ * $FreeBSD$
+ * created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.132 2010/06/28 18:06:46 kib Exp
*/
#ifndef _FREEBSD32_SYSPROTO_H_
@@ -564,6 +564,27 @@
char ts_l_[PADL_(const struct timespec32 *)]; const struct timespec32 * ts; char ts_r_[PADR_(const struct timespec32 *)];
char sm_l_[PADL_(const sigset_t *)]; const sigset_t * sm; char sm_r_[PADR_(const sigset_t *)];
};
+struct makenewjob_args {
+ char rjid_l_[PADL_(jid_t)]; jid_t rjid; char rjid_r_[PADR_(jid_t)];
+ char user_l_[PADL_(__uid_t)]; __uid_t user; char user_r_[PADR_(__uid_t)];
+};
+struct killjob_args {
+ char jid_l_[PADL_(jid_t)]; jid_t jid; char jid_r_[PADR_(jid_t)];
+ char signal_l_[PADL_(int)]; int signal; char signal_r_[PADR_(int)];
+};
+struct getjid_args {
+ register_t dummy;
+};
+struct getjlimit_args {
+ char jid_l_[PADL_(jid_t)]; jid_t jid; char jid_r_[PADR_(jid_t)];
+ char resource_l_[PADL_(int)]; int resource; char resource_r_[PADR_(int)];
+ char rlp_l_[PADL_(struct rlimit *)]; struct rlimit * rlp; char rlp_r_[PADR_(struct rlimit *)];
+};
+struct setjlimit_args {
+ char jid_l_[PADL_(jid_t)]; jid_t jid; char jid_r_[PADR_(jid_t)];
+ char resource_l_[PADL_(int)]; int resource; char resource_r_[PADR_(int)];
+ char rlp_l_[PADL_(struct rlimit *)]; struct rlimit * rlp; char rlp_r_[PADR_(struct rlimit *)];
+};
#if !defined(PAD64_REQUIRED) && defined(__powerpc__)
#define PAD64_REQUIRED
#endif
@@ -671,6 +692,11 @@
int freebsd32_msgctl(struct thread *, struct freebsd32_msgctl_args *);
int freebsd32_shmctl(struct thread *, struct freebsd32_shmctl_args *);
int freebsd32_pselect(struct thread *, struct freebsd32_pselect_args *);
+int makenewjob(struct thread *, struct makenewjob_args *);
+int killjob(struct thread *, struct killjob_args *);
+int getjid(struct thread *, struct getjid_args *);
+int getjlimit(struct thread *, struct getjlimit_args *);
+int setjlimit(struct thread *, struct setjlimit_args *);
#ifdef COMPAT_43
@@ -1000,6 +1026,11 @@
#define FREEBSD32_SYS_AUE_freebsd32_msgctl AUE_MSGCTL
#define FREEBSD32_SYS_AUE_freebsd32_shmctl AUE_SHMCTL
#define FREEBSD32_SYS_AUE_freebsd32_pselect AUE_SELECT
+#define FREEBSD32_SYS_AUE_makenewjob AUE_NULL
+#define FREEBSD32_SYS_AUE_killjob AUE_NULL
+#define FREEBSD32_SYS_AUE_getjid AUE_NULL
+#define FREEBSD32_SYS_AUE_getjlimit AUE_NULL
+#define FREEBSD32_SYS_AUE_setjlimit AUE_NULL
#undef PAD_
#undef PADL_
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/freebsd32_syscall.h#2 (text+ko) ====
@@ -2,8 +2,8 @@
* System call numbers.
*
* DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD: src/sys/compat/freebsd32/freebsd32_syscall.h,v 1.112 2010/06/28 18:17:21 kib Exp $
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 209579 2010-06-28 18:06:46Z kib
+ * $FreeBSD$
+ * created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.132 2010/06/28 18:06:46 kib Exp
*/
#define FREEBSD32_SYS_syscall 0
@@ -410,4 +410,9 @@
#define FREEBSD32_SYS_freebsd32_shmctl 512
#define FREEBSD32_SYS_lpathconf 513
#define FREEBSD32_SYS_freebsd32_pselect 522
-#define FREEBSD32_SYS_MAXSYSCALL 523
+#define FREEBSD32_SYS_makenewjob 523
+#define FREEBSD32_SYS_killjob 524
+#define FREEBSD32_SYS_getjid 525
+#define FREEBSD32_SYS_getjlimit 526
+#define FREEBSD32_SYS_setjlimit 527
+#define FREEBSD32_SYS_MAXSYSCALL 528
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/freebsd32_syscalls.c#2 (text+ko) ====
@@ -2,8 +2,8 @@
* System call names.
*
* DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD: src/sys/compat/freebsd32/freebsd32_syscalls.c,v 1.103 2010/06/28 18:17:21 kib Exp $
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 209579 2010-06-28 18:06:46Z kib
+ * $FreeBSD$
+ * created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.132 2010/06/28 18:06:46 kib Exp
*/
const char *freebsd32_syscallnames[] = {
@@ -546,4 +546,9 @@
"#520", /* 520 = pdgetpid */
"#521", /* 521 = pdwait */
"freebsd32_pselect", /* 522 = freebsd32_pselect */
+ "makenewjob", /* 523 = makenewjob */
+ "killjob", /* 524 = killjob */
+ "getjid", /* 525 = getjid */
+ "getjlimit", /* 526 = getjlimit */
+ "setjlimit", /* 527 = setjlimit */
};
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/freebsd32_sysent.c#2 (text+ko) ====
@@ -2,8 +2,8 @@
* System call switch table.
*
* DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD: src/sys/compat/freebsd32/freebsd32_sysent.c,v 1.114 2010/06/28 18:17:21 kib Exp $
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 209579 2010-06-28 18:06:46Z kib
+ * $FreeBSD$
+ * created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.132 2010/06/28 18:06:46 kib Exp
*/
#include "opt_compat.h"
@@ -583,4 +583,9 @@
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 520 = pdgetpid */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 521 = pdwait */
{ AS(freebsd32_pselect_args), (sy_call_t *)freebsd32_pselect, AUE_SELECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 522 = freebsd32_pselect */
+ { AS(makenewjob_args), (sy_call_t *)makenewjob, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 523 = makenewjob */
+ { AS(killjob_args), (sy_call_t *)killjob, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 524 = killjob */
+ { 0, (sy_call_t *)getjid, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 525 = getjid */
+ { AS(getjlimit_args), (sy_call_t *)getjlimit, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 526 = getjlimit */
+ { AS(setjlimit_args), (sy_call_t *)setjlimit, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 527 = setjlimit */
};
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/compat/freebsd32/syscalls.master#2 (text+ko) ====
@@ -962,3 +962,11 @@
fd_set *ou, fd_set *ex, \
const struct timespec32 *ts, \
const sigset_t *sm); }
+523 AUE_NULL STD { jid_t makenewjob(jid_t rjid,\
+ __uid_t user); }
+524 AUE_NULL STD { int killjob(jid_t jid, int signal); }
+525 AUE_NULL STD { jid_t getjid(void); }
+526 AUE_NULL STD { int getjlimit(jid_t jid, int resource, \
+ struct rlimit *rlp); }
+527 AUE_NULL STD { int setjlimit(jid_t jid, int resource, \
+ struct rlimit *rlp); }
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/conf/files#3 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.1523 2010/06/30 21:05:51 jfv Exp $
+# $FreeBSD: src/sys/conf/files,v 1.1524 2010/07/15 11:26:07 bschmidt Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -1220,7 +1220,21 @@
clean "iwn6000fw.fwo"
iwn6000.fw optional iwn6000fw | iwnfw \
dependency ".PHONY" \
- compile-with "uudecode -o ${.TARGET} $S/contrib/dev/iwn/iwlwifi-6000-9.193.4.1.fw.uu" \
+ compile-with "uudecode -o ${.TARGET} $S/contrib/dev/iwn/iwlwifi-6000-9.221.4.1.fw.uu" \
+ no-obj no-implicit-rule \
+ clean "iwn6000.fw"
+iwn6050fw.c optional iwn6050fw | iwnfw \
+ compile-with "${AWK} -f $S/tools/fw_stub.awk iwn6050.fw:iwn6050fw -miwn6050fw -c${.TARGET}" \
+ no-implicit-rule before-depend local \
+ clean "iwn6050fw.c"
+iwn6050fw.fwo optional iwn6050fw | iwnfw \
+ dependency "iwn6050.fw" \
+ compile-with "${LD} -b binary -d -warn-common -r -d -o ${.TARGET} iwn6050.fw" \
+ no-implicit-rule \
+ clean "iwn6050fw.fwo"
+iwn6050.fw optional iwn6050fw | iwnfw \
+ dependency ".PHONY" \
+ compile-with "uudecode -o ${.TARGET} $S/contrib/dev/iwn/iwlwifi-6050-9.201.4.1.fw.uu" \
no-obj no-implicit-rule \
clean "iwn6000.fw"
dev/ixgb/if_ixgb.c optional ixgb
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/kern/kern_fork.c#3 (text+ko) ====
@@ -105,16 +105,16 @@
int error;
struct proc *p2;
-// error = irix_jobs_alloc(td->td_proc, JLIMIT_NUMPROC, 1);
-// if (error != 0)
-// returnv(error);
+ error = irix_jobs_alloc(td->td_proc, JLIMIT_NUMPROC, 1);
+ if (error != 0)
+ return (error);
error = fork1(td, RFFDG | RFPROC, 0, &p2);
if (error == 0) {
td->td_retval[0] = p2->p_pid;
td->td_retval[1] = 0;
- if (td->td_proc->p_ucred->cr_jid != 0)
- irix_jobs_add_proc(td->td_proc->p_ucred->cr_jid, p2->p_pid);
+ if (td->td_proc->p_ucred->cr_jid != 0)
+ irix_jobs_add_proc(td->td_proc->p_ucred->cr_jid, p2->p_pid);
}
return (error);
}
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/kern/kern_jobs.c#4 (text+ko) ====
@@ -285,7 +285,7 @@
JOBLIST_WLOCK;
LIST_FOREACH(jp, &irix_joblist, entries) {
if (jp->jid == jid) {
- if (jp->limits[resource].rlim_max != RLIM_INFINITY &&
+ if ((jp->limits[resource].rlim_max != RLIM_INFINITY) &&
(jp->usage[resource] + amount >
jp->limits[resource].rlim_max)) {
/* limit exceeded */
@@ -339,18 +339,6 @@
JOBLIST_WUNLOCK;
}
-jid_t
-getjid_by_pid(pid_t pid)
-{
-// struct proc *p;
-
-// LIST_FOREACH(p, &proclist, proclist) {
-// if (p->p_pid == pid)
-// return (p->p_ucred->cr_jid);
-// }
- return (0);
-}
-
void
irix_jobs_remove_proc(jid_t jid, pid_t pid)
{
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/kern/syscalls.master#3 (text+ko) ====
@@ -922,13 +922,13 @@
fd_set *ou, fd_set *ex, \
const struct timespec *ts, \
const sigset_t *sm); }
-523 AUE_NULL STD { __jid_t makenewjob(__jid_t rjid,\
+523 AUE_NULL STD { jid_t makenewjob(jid_t rjid,\
__uid_t user); }
-524 AUE_NULL STD { int killjob(__jid_t jid, int signal); }
-525 AUE_NULL STD { __jid_t getjid(void); }
-526 AUE_NULL STD { int getjlimit(__jid_t jid, int resource, \
+524 AUE_NULL STD { int killjob(jid_t jid, int signal); }
+525 AUE_NULL STD { jid_t getjid(void); }
+526 AUE_NULL STD { int getjlimit(jid_t jid, int resource, \
struct rlimit *rlp); }
-527 AUE_NULL STD { int setjlimit(__jid_t jid, int resource, \
+527 AUE_NULL STD { int setjlimit(jid_t jid, int resource, \
struct rlimit *rlp); }
; Please copy any additions and changes to the following compatability tables:
; sys/compat/freebsd32/syscalls.master
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/kern/systrace_args.c#3 (text+ko) ====
@@ -3087,7 +3087,7 @@
/* makenewjob */
case 523: {
struct makenewjob_args *p = params;
- iarg[0] = p->rjid; /* __jid_t */
+ iarg[0] = p->rjid; /* jid_t */
iarg[1] = p->user; /* __uid_t */
*n_args = 2;
break;
@@ -3095,7 +3095,7 @@
/* killjob */
case 524: {
struct killjob_args *p = params;
- iarg[0] = p->jid; /* __jid_t */
+ iarg[0] = p->jid; /* jid_t */
iarg[1] = p->signal; /* int */
*n_args = 2;
break;
@@ -3108,7 +3108,7 @@
/* getjlimit */
case 526: {
struct getjlimit_args *p = params;
- iarg[0] = p->jid; /* __jid_t */
+ iarg[0] = p->jid; /* jid_t */
iarg[1] = p->resource; /* int */
uarg[2] = (intptr_t) p->rlp; /* struct rlimit * */
*n_args = 3;
@@ -3117,7 +3117,7 @@
/* setjlimit */
case 527: {
struct setjlimit_args *p = params;
- iarg[0] = p->jid; /* __jid_t */
+ iarg[0] = p->jid; /* jid_t */
iarg[1] = p->resource; /* int */
uarg[2] = (intptr_t) p->rlp; /* struct rlimit * */
*n_args = 3;
@@ -8234,7 +8234,7 @@
case 523:
switch(ndx) {
case 0:
- p = "__jid_t";
+ p = "jid_t";
break;
case 1:
p = "__uid_t";
@@ -8247,7 +8247,7 @@
case 524:
switch(ndx) {
case 0:
- p = "__jid_t";
+ p = "jid_t";
break;
case 1:
p = "int";
@@ -8263,7 +8263,7 @@
case 526:
switch(ndx) {
case 0:
- p = "__jid_t";
+ p = "jid_t";
break;
case 1:
p = "int";
@@ -8279,7 +8279,7 @@
case 527:
switch(ndx) {
case 0:
- p = "__jid_t";
+ p = "jid_t";
break;
case 1:
p = "int";
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/_types.h#4 (text+ko) ====
@@ -45,7 +45,7 @@
typedef __int64_t __id_t; /* can hold a gid_t, pid_t, uid_t
or jid_t */
typedef __uint32_t __ino_t; /* inode number */
-typedef __int64_t __jid_t; /* job id (for IRIX jobs) */
+typedef __int32_t __jid_t; /* job id (for IRIX jobs) */
typedef long __key_t; /* IPC key (for Sys V IPC) */
typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
typedef __uint16_t __mode_t; /* permissions */
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/resource.h#3 (text+ko) ====
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* @(#)resource.h 8.4 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/sys/resource.h,v 1.36 2010/05/04 05:55:37 kib Exp $
+ * $FreeBSD: src/sys/sys/resource.h,v 1.38 2010/07/18 11:13:36 trasz Exp $
*/
#ifndef _SYS_RESOURCE_H_
@@ -93,7 +93,7 @@
#define RLIMIT_NPROC 7 /* number of processes */
#define RLIMIT_NOFILE 8 /* number of open files */
#define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */
-#define RLIMIT_VMEM 10 /* virtual process size (inclusive of mmap) */
+#define RLIMIT_VMEM 10 /* virtual process size (incl. mmap) */
#define RLIMIT_AS RLIMIT_VMEM /* standard name for RLIMIT_VMEM */
#define RLIMIT_NPTS 11 /* pseudo-terminals */
#define RLIMIT_SWAP 12 /* swap used */
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/sysproto.h#3 (text+ko) ====
@@ -1650,23 +1650,23 @@
char sm_l_[PADL_(const sigset_t *)]; const sigset_t * sm; char sm_r_[PADR_(const sigset_t *)];
};
struct makenewjob_args {
- char rjid_l_[PADL_(__jid_t)]; __jid_t rjid; char rjid_r_[PADR_(__jid_t)];
+ char rjid_l_[PADL_(jid_t)]; jid_t rjid; char rjid_r_[PADR_(jid_t)];
char user_l_[PADL_(__uid_t)]; __uid_t user; char user_r_[PADR_(__uid_t)];
};
struct killjob_args {
- char jid_l_[PADL_(__jid_t)]; __jid_t jid; char jid_r_[PADR_(__jid_t)];
+ char jid_l_[PADL_(jid_t)]; jid_t jid; char jid_r_[PADR_(jid_t)];
char signal_l_[PADL_(int)]; int signal; char signal_r_[PADR_(int)];
};
struct getjid_args {
register_t dummy;
};
struct getjlimit_args {
- char jid_l_[PADL_(__jid_t)]; __jid_t jid; char jid_r_[PADR_(__jid_t)];
+ char jid_l_[PADL_(jid_t)]; jid_t jid; char jid_r_[PADR_(jid_t)];
char resource_l_[PADL_(int)]; int resource; char resource_r_[PADR_(int)];
char rlp_l_[PADL_(struct rlimit *)]; struct rlimit * rlp; char rlp_r_[PADR_(struct rlimit *)];
};
struct setjlimit_args {
- char jid_l_[PADL_(__jid_t)]; __jid_t jid; char jid_r_[PADR_(__jid_t)];
+ char jid_l_[PADL_(jid_t)]; jid_t jid; char jid_r_[PADR_(jid_t)];
char resource_l_[PADL_(int)]; int resource; char resource_r_[PADR_(int)];
char rlp_l_[PADL_(struct rlimit *)]; struct rlimit * rlp; char rlp_r_[PADR_(struct rlimit *)];
};
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/types.h#3 (text+ko) ====
@@ -190,6 +190,11 @@
#define _INO_T_DECLARED
#endif
+#ifndef _JID_T_DECLARED
+typedef __jid_t jid_t; /* job id for IRIX jobs */
+#define _JID_T_DECLARED
+#endif
+
#ifndef _KEY_T_DECLARED
typedef __key_t key_t; /* IPC key (for Sys V IPC) */
#define _KEY_T_DECLARED
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/sys/sys/ucred.h#3 (text+ko) ====
@@ -33,7 +33,6 @@
#ifndef _SYS_UCRED_H_
#define _SYS_UCRED_H_
-#include <sys/resource.h>
#include <bsm/audit.h>
/*
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/tools/test/irix_jobs/Makefile#2 (text+ko) ====
@@ -6,4 +6,18 @@
WARNS?= 6
CFLAGS+= -ggdb
+test: jobtest
+ @${ECHO} "Testing makenewjob() and getjid()"
+ @${.CURDIR}/jobtest -j \
+ && ${ECHO} "OK" \
+ || ${ECHO} "FAIL"
+ @${ECHO} "Testing forking processes without procees limit exceeding"
+ @${.CURDIR}/jobtest -j -f 2 -n 5 \
+ && ${ECHO} "OK" \
+ || ${ECHO} "FAIL"
+ @${ECHO} "Testing forking processes with procees limit exceeding"
+ @${.CURDIR}/jobtest -j -f 5 -n 5 \
+ && ${ECHO} "FAIL" \
+ || ${ECHO} "OK"
+
.include <bsd.prog.mk>
==== //depot/projects/soc2010/gabor_jobs/irix_jobs/tools/test/irix_jobs/jobtest.c#2 (text+ko) ====
@@ -56,7 +56,7 @@
static unsigned long long fflag;
static bool jflag;
static bool kflag;
-static rlim_t nflag;
+static long long nflag;
static bool sflag;
static int null_print(const char * restrict, ...);
@@ -115,13 +115,13 @@
case 'n':
errno = 0;
nflag = strtoll(optarg, &ep, 10);
-// if (((errno == ERANGE) && (nflag == LLONG_MAX)) ||
-// ((errno == EINVAL) && (nflag == 0)))
-// err(2, NULL);
-// else if (ep[0] != '\0') {
-// errno = EINVAL;
-// err(2, NULL);
-// }
+ if (((errno == ERANGE) && (nflag == LLONG_MAX)) ||
+ ((errno == EINVAL) && (nflag == 0)))
+ err(2, NULL);
+ else if (ep[0] != '\0') {
+ errno = EINVAL;
+ err(2, NULL);
+ }
break;
case 's':
sflag = true;
@@ -135,6 +135,8 @@
usage();
if (jflag) {
+ jid_t jid_tmp;
+
jid = makenewjob((jid_t)0, (uid_t)0);
if (jid == (jid_t)-1) {
diag_print("makenewjob() failed: %s.\n",
@@ -143,14 +145,19 @@
}
diag_print("New job created, jod id is %d.\n", (int)jid);
- diag_print("getjid() returns: %d.\n", (int)getjid());
+
+ jid_tmp = getjid();
+ diag_print("getjid() returns: %d.\n", (int)jid_tmp);
+ if (jid_tmp != jid)
+ return (1);
}
if (nflag > 0) {
int ret;
struct rlimit rlp;
- rlp.rlim_max = nflag;
+ rlp.rlim_cur = (rlim_t)nflag;
+ rlp.rlim_max = (rlim_t)nflag;
ret = setjlimit(jid, JLIMIT_NUMPROC, &rlp);
@@ -159,8 +166,8 @@
strerror(errno));
return (1);
} else
- diag_print("JLIMIT_NUMPROC limit set to %ll.\n",
- nflag);
+ diag_print("JLIMIT_NUMPROC limit set to %lld.\n",
+ nflag);
ret = getjlimit(jid, JLIMIT_NUMPROC, &rlp);
@@ -168,7 +175,9 @@
diag_print("getjlimit() failed: %s.\n",
strerror(errno));
return (1);
- }
+ } else
+ diag_print("getjlimit() says JLIMIT_NUMPROC limit is"
+ "set to %lld/%lld.\n", rlp.rlim_cur, rlp.rlim_max);
}
if (fflag > 0) {
@@ -178,8 +187,13 @@
diag_print("Forked process' getjid() returns: %d.\n",
(int)getjid());
sleep(5);
- } else if (pid == -1)
- strerror(errno);
+ exit(EXIT_SUCCESS);
+ } else if (pid == -1) {
+ diag_print("fork(): %s\n", strerror(errno));
+ return (2);
+ } else
+ diag_print("Forked process with pid %d.\n",
+ (int)pid);
}
}
@@ -196,8 +210,8 @@
if (kflag && (pid != 0)) {
int ret;
- diag_print("Let's suicide, sending SIGINT...\n");
- ret = killjob(jid, SIGINT);
+ diag_print("Let's suicide, sending SIGINT to processes of jid %lld...\n", getjid());
+ ret = killjob(getjid(), SIGINT);
if (ret == -1) {
diag_print("killjob() failed: %s.\n",
strerror(errno));
More information about the p4-projects
mailing list