Skip to content

Commit 8af62fe

Browse files
IgorTodorovskiIBMkhwilliamson
authored andcommitted
Restructure handling extra statbuf flags on z/OS
z/OS has extra fields which give the character set associated with the object. Previously, there were a bunch of functions called to deal with these. This all falls away if we #ifdef these fields when accessing the structure.
1 parent 64b69ef commit 8af62fe

File tree

4 files changed

+14
-113
lines changed

4 files changed

+14
-113
lines changed

doio.c

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -222,57 +222,6 @@ Perl_PerlLIO_dup2_cloexec(pTHX_ int oldfd, int newfd)
222222
#endif
223223
}
224224

225-
#if defined(OEMVS)
226-
#if (__CHARSET_LIB == 1)
227-
# include <stdio.h>
228-
# include <stdlib.h>
229-
230-
static int setccsid(int fd, int ccsid)
231-
{
232-
attrib_t attr;
233-
int rc;
234-
235-
memset(&attr, 0, sizeof(attr));
236-
attr.att_filetagchg = 1;
237-
attr.att_filetag.ft_ccsid = ccsid;
238-
attr.att_filetag.ft_txtflag = 1;
239-
240-
rc = __fchattr(fd, &attr, sizeof(attr));
241-
return rc;
242-
}
243-
244-
static void updateccsid(int fd, const char* path, int oflag, int perm)
245-
{
246-
int rc;
247-
if (oflag & O_CREAT) {
248-
rc = setccsid(fd, 819);
249-
}
250-
}
251-
252-
int asciiopen(const char* path, int oflag)
253-
{
254-
int rc;
255-
int fd = open(path, oflag);
256-
if (fd == -1) {
257-
return fd;
258-
}
259-
updateccsid(fd, path, oflag, -1);
260-
return fd;
261-
}
262-
263-
int asciiopen3(const char* path, int oflag, int perm)
264-
{
265-
int rc;
266-
int fd = open(path, oflag, perm);
267-
if (fd == -1) {
268-
return fd;
269-
}
270-
updateccsid(fd, path, oflag, perm);
271-
return fd;
272-
}
273-
#endif
274-
#endif
275-
276225
int
277226
Perl_PerlLIO_open_cloexec(pTHX_ const char *file, int flag)
278227
{
@@ -302,9 +251,6 @@ Perl_PerlLIO_open3_cloexec(pTHX_ const char *file, int flag, int perm)
302251
}
303252

304253
#if defined(OEMVS)
305-
#if (__CHARSET_LIB == 1)
306-
#define TEMP_CCSID 819
307-
#endif
308254
static int Internal_Perl_my_mkstemp_cloexec(char *templte)
309255
{
310256
PERL_ARGS_ASSERT_MY_MKSTEMP_CLOEXEC;
@@ -321,9 +267,6 @@ int
321267
Perl_my_mkstemp_cloexec(char *templte)
322268
{
323269
int tempfd = Internal_Perl_my_mkstemp_cloexec(templte);
324-
# if defined(TEMP_CCSID)
325-
setccsid(tempfd, TEMP_CCSID);
326-
# endif
327270
return tempfd;
328271
}
329272

@@ -1471,6 +1414,10 @@ Perl_nextargv(pTHX_ GV *gv, bool nomagicopen)
14711414
#endif
14721415
PL_filemode = statbuf.st_mode;
14731416
fileuid = statbuf.st_uid;
1417+
#ifdef __MVS__
1418+
int txtflag = statbuf.st_tag.ft_txtflag;
1419+
int ccsid = statbuf.st_tag.ft_ccsid;
1420+
#endif
14741421
filegid = statbuf.st_gid;
14751422
if (!S_ISREG(PL_filemode)) {
14761423
ck_warner_d(packWARN(WARN_INPLACE),
@@ -1548,6 +1495,9 @@ Perl_nextargv(pTHX_ GV *gv, bool nomagicopen)
15481495
PL_lastfd = PerlIO_fileno(IoIFP(GvIOp(PL_argvoutgv)));
15491496
if (PL_lastfd >= 0) {
15501497
(void)PerlLIO_fstat(PL_lastfd,&statbuf);
1498+
#ifdef __MVS__
1499+
__setfdccsid(PL_lastfd, (txtflag << 16) | ccsid);
1500+
#endif
15511501
#ifdef HAS_FCHMOD
15521502
(void)fchmod(PL_lastfd,PL_filemode);
15531503
#else
@@ -2558,6 +2508,11 @@ Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
25582508
}
25592509
doshell:
25602510
PERL_FPU_PRE_EXEC
2511+
#if defined(OEMVS)
2512+
#if (__CHARSET_LIB == 1)
2513+
unsetenv("_TAG_REDIR_ERR");
2514+
#endif
2515+
#endif
25612516
PerlProc_execl(PL_sh_path, "sh", "-c", cmd, (char *)NULL);
25622517
PERL_FPU_POST_EXEC
25632518
S_exec_failed(aTHX_ PL_sh_path, fd, do_report);

installperl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ else {
284284
strip("$installbin/$perl_verbase$ver$exe_ext");
285285
fix_dep_names("$installbin/$perl_verbase$ver$exe_ext");
286286
chmod(0755, "$installbin/$perl_verbase$ver$exe_ext");
287-
`chtag -r "$installbin/$perl_verbase$ver$exe_ext"` if ($^O eq 'os390');
288287
}
289288

290289
# Install library files.
@@ -355,7 +354,6 @@ foreach my $file (@corefiles) {
355354
} else {
356355
chmod($NON_SO_MODE, "$installarchlib/CORE/$file");
357356
}
358-
`chtag -r "$installarchlib/CORE/$file"` if ($^O eq 'os390');
359357
}
360358
}
361359

@@ -424,7 +422,6 @@ if ($Config{installusrbinperl} && $Config{installusrbinperl} eq 'define' &&
424422
eval { CORE::link $instperl, $usrbinperl } ) ||
425423
eval { symlink $expinstperl, $usrbinperl } ||
426424
copy($instperl, $usrbinperl);
427-
`chtag -r "$usrbinperl"` if ($^O eq 'os390');
428425

429426
$mainperl_is_instperl = 1;
430427
}
@@ -719,7 +716,6 @@ sub copy_if_diff {
719716
my ($atime, $mtime) = (stat $from)[8,9];
720717
utime $atime, $mtime, $to;
721718
}
722-
`chtag -r "$to"` if ($^O eq "os390");
723719
1;
724720
}
725721
}

iperlsys.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -770,21 +770,8 @@ struct IPerlLIOInfo
770770
# define PerlLIO_lstat(name, buf) PerlLIO_stat((name), (buf))
771771
# endif
772772
# define PerlLIO_mktemp(file) mktemp((file))
773-
# if defined(OEMVS)
774-
# if (__CHARSET_LIB == 1)
775-
int asciiopen(const char* path, int oflag);
776-
int asciiopen3(const char* path, int oflag, int perm);
777-
778-
# define PerlLIO_open(file, flag) asciiopen((file), (flag))
779-
# define PerlLIO_open3(file, flag, perm) asciiopen3((file), (flag), (perm))
780-
# else
781-
# define PerlLIO_open(file, flag) open((file), (flag))
782-
# define PerlLIO_open3(file, flag, perm) open((file), (flag), (perm))
783-
# endif
784-
# else
785-
# define PerlLIO_open(file, flag) open((file), (flag))
786-
# define PerlLIO_open3(file, flag, perm) open((file), (flag), (perm))
787-
# endif
773+
# define PerlLIO_open(file, flag) open((file), (flag))
774+
# define PerlLIO_open3(file, flag, perm) open((file), (flag), (perm))
788775
# define PerlLIO_read(fd, buf, count) read((fd), (buf), (count))
789776
# define PerlLIO_rename(old, new) rename((old), (new))
790777
# define PerlLIO_setmode(fd, mode) setmode((fd), (mode))

util.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,12 +2534,6 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args)
25342534
/* Close parent's end of error status pipe (if any) */
25352535
if (did_pipes)
25362536
PerlLIO_close(pp[0]);
2537-
#if defined(OEMVS)
2538-
#if (__CHARSET_LIB == 1)
2539-
chgfdccsid(p[THIS], 819);
2540-
chgfdccsid(p[THAT], 819);
2541-
#endif
2542-
#endif
25432537
/* Now dup our end of _the_ pipe to right position */
25442538
if (p[THIS] != (*mode == 'r')) {
25452539
PerlLIO_dup2(p[THIS], *mode == 'r');
@@ -2615,20 +2609,7 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args)
26152609
}
26162610
if (did_pipes)
26172611
PerlLIO_close(pp[0]);
2618-
#if defined(OEMVS)
2619-
#if (__CHARSET_LIB == 1)
2620-
PerlIO* io = PerlIO_fdopen(p[This], mode);
2621-
if (io) {
2622-
chgfdccsid(p[This], 819);
2623-
}
2624-
return io;
2625-
#else
2626-
return PerlIO_fdopen(p[This], mode);
2627-
#endif
2628-
#else
26292612
return PerlIO_fdopen(p[This], mode);
2630-
#endif
2631-
26322613
#else
26332614
# if defined(OS2) /* Same, without fork()ing and all extra overhead... */
26342615
return my_syspopen4(aTHX_ NULL, mode, n, args);
@@ -2706,12 +2687,6 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode)
27062687
#define THAT This
27072688
if (did_pipes)
27082689
PerlLIO_close(pp[0]);
2709-
#if defined(OEMVS)
2710-
#if (__CHARSET_LIB == 1)
2711-
chgfdccsid(p[THIS], 819);
2712-
chgfdccsid(p[THAT], 819);
2713-
#endif
2714-
#endif
27152690
if (p[THIS] != (*mode == 'r')) {
27162691
PerlLIO_dup2(p[THIS], *mode == 'r');
27172692
PerlLIO_close(p[THIS]);
@@ -2798,19 +2773,7 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode)
27982773
}
27992774
if (did_pipes)
28002775
PerlLIO_close(pp[0]);
2801-
#if defined(OEMVS)
2802-
#if (__CHARSET_LIB == 1)
2803-
PerlIO* io = PerlIO_fdopen(p[This], mode);
2804-
if (io) {
2805-
chgfdccsid(p[This], 819);
2806-
}
2807-
return io;
2808-
#else
28092776
return PerlIO_fdopen(p[This], mode);
2810-
#endif
2811-
#else
2812-
return PerlIO_fdopen(p[This], mode);
2813-
#endif
28142777
}
28152778
#elif defined(__LIBCATAMOUNT__)
28162779
PerlIO *

0 commit comments

Comments
 (0)