X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=vms%2Fvms.c;h=84330e2f98e355111ca5cb687ec38a39909ca79c;hb=88bf70ddad663558df6e83dce8f369f639fc7dd6;hp=6f4b14669b7e5dba255a7184141b196c45936c04;hpb=809a5acc2df9d5b3c0528c9c63a1f59bbe24b2cf;p=p5sagit%2Fp5-mst-13.2.git diff --git a/vms/vms.c b/vms/vms.c index 6f4b146..84330e2 100644 --- a/vms/vms.c +++ b/vms/vms.c @@ -456,9 +456,9 @@ kill_file(char *name) /*}}}*/ -/*{{{int my_mkdir(char *,mode_t)*/ +/*{{{int my_mkdir(char *,Mode_t)*/ int -my_mkdir(char *dir, mode_t mode) +my_mkdir(char *dir, Mode_t mode) { STRLEN dirlen = strlen(dir); @@ -1759,7 +1759,7 @@ static int background_process(int argc, char **argv); static void pipe_and_fork(char **cmargv); /*{{{ void getredirection(int *ac, char ***av)*/ -void +static void getredirection(int *ac, char ***av) /* * Process vms redirection arg's. Exit if any error is seen. @@ -2221,6 +2221,34 @@ unsigned long int flags = 17, one = 1, retsts; /*}}}*/ /***** End of code taken from Mark Pizzolato's argproc.c package *****/ + +/* OS-specific initialization at image activation (not thread startup) */ +/*{{{void vms_image_init(int *, char ***)*/ +void +vms_image_init(int *argcp, char ***argvp) +{ + unsigned long int *mask, iosb[2], i; + unsigned short int dummy; + union prvdef iprv; + struct itmlst_3 jpilist[2] = { {sizeof iprv, JPI$_IMAGPRIV, &iprv, &dummy}, + { 0, 0, 0, 0} }; + + _ckvmssts(sys$getjpiw(0,NULL,NULL,jpilist,iosb,NULL,NULL)); + _ckvmssts(iosb[0]); + mask = (unsigned long int *) &iprv; /* Quick change of view */; + for (i = 0; i < (sizeof iprv + sizeof(unsigned long int) - 1) / sizeof(unsigned long int); i++) { + if (mask[i]) { /* Running image installed with privs? */ + _ckvmssts(sys$setprv(0,&iprv,0,NULL)); /* Turn 'em off. */ + tainting = TRUE; + break; + } + } + getredirection(argcp,argvp); + return; +} +/*}}}*/ + + /* trim_unixpath() * Trim Unix-style prefix off filespec, so it looks like what a shell * glob expansion would return (i.e. from specified prefix on, not @@ -3150,6 +3178,79 @@ void my_endpwent() } /*}}}*/ +#if __VMS_VER < 70000000 || __DECC_VER < 50200000 +/* Signal handling routines, pulled into the core from POSIX.xs. + * + * We need these for threads, so they've been rolled into the core, + * rather than left in POSIX.xs. + * + * (DRS, Oct 23, 1997) + */ + +/* sigset_t is atomic under VMS, so these routines are easy */ +int my_sigemptyset(sigset_t *set) { + if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; } + *set = 0; return 0; +} +int my_sigfillset(sigset_t *set) { + int i; + if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; } + for (i = 0; i < NSIG; i++) *set |= (1 << i); + return 0; +} +int my_sigaddset(sigset_t *set, int sig) { + if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; } + if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; } + *set |= (1 << (sig - 1)); + return 0; +} +int my_sigdelset(sigset_t *set, int sig) { + if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; } + if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; } + *set &= ~(1 << (sig - 1)); + return 0; +} +int my_sigismember(sigset_t *set, int sig) { + if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; } + if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; } + *set & (1 << (sig - 1)); +} +int my_sigprocmask(int how, sigset_t *set, sigset_t *oset) { + sigset_t tempmask; + + /* If set and oset are both null, then things are badky wrong. Bail */ + if ((oset == NULL) && (set == NULL)) { + set_errno(EFAULT); set_vaxc_errno(SS$_ACCVIO); + return -1; + } + + /* If set's null, then we're just handling a fetch. */ + if (set == NULL) { + tempmask = sigblock(0); + } else { + switch (how) { + case SIG_SETMASK: + tempmask = sigsetmask(*set); + break; + case SIG_BLOCK: + tempmask = sigblock(*set); + break; + case SIG_UNBLOCK: + tempmask = sigblock(0); + sigsetmask(*oset & ~tempmask); + break; + default: + set_errno(EINVAL); set_vaxc_errno(LIB$_INVARG); + return -1; + } + } + + /* Did they pass us an oset? If so, stick our holding mask into it */ + if (oset) + *oset = tempmask; + + return 0; +} /* Used for UTC calculation in my_gmtime(), my_localtime(), my_time(), * my_utime(), and flex_stat(), all of which operate on UTC unless @@ -3279,6 +3380,7 @@ my_localtime(const time_t *timep) #define localtime(t) my_localtime(t) #define time(t) my_time(t) +#endif /* VMS VER < 7.0 || Dec C < 5.2 /* my_utime - update modification time of a file * calling sequence is identical to POSIX utime(), but under @@ -3343,7 +3445,7 @@ int my_utime(char *file, struct utimbuf *utimes) */ lowbit = (utimes->modtime & 1) ? secscale : 0; unixtime = (long int) utimes->modtime; -# ifdef VMSISH_TIME +#if defined(VMSISH_TIME) && (__VMS_VER < 70000000 || __DECC_VER < 50200000) if (!VMSISH_TIME) { /* Input was UTC; convert to local for sys svc */ if (!gmtime_emulation_type) (void) time(NULL); /* Initialize UTC */ unixtime += utc_offset_secs; @@ -3695,10 +3797,12 @@ flex_fstat(int fd, struct mystat *statbufp) # else if (1) { # endif +#if __VMS_VER < 70000000 || __DECC_VER < 50200000 if (!gmtime_emulation_type) (void)time(NULL); statbufp->st_mtime -= utc_offset_secs; statbufp->st_atime -= utc_offset_secs; statbufp->st_ctime -= utc_offset_secs; +#endif } return 0; } @@ -3749,10 +3853,12 @@ flex_stat(char *fspec, struct mystat *statbufp) # else if (1) { # endif +#if __VMS_VER < 70000000 || __DECC_VER < 50200000 if (!gmtime_emulation_type) (void)time(NULL); statbufp->st_mtime -= utc_offset_secs; statbufp->st_atime -= utc_offset_secs; statbufp->st_ctime -= utc_offset_secs; +#endif } } return retval;