Re: [blead-498-gb94a8c4] vms chdir/chmod/mkdir... thread contextdependency removal
[email protected] (John Malmberg)
| Newsgroups | perl.perl5.porters,perl.vmsperl |
|---|---|
| Message-ID | <[email protected]> |
Craig A. Berry wrote: > > On Feb 4, 2009, at 8:43 AM, John Malmberg wrote: > >> Getting close to the end of the list of patches to vms.c/vmsish.h for >> thread context and Unix / Extended file specification support. >> >> This removes the dependencies on the thread context from the mkdir, >> chdir, chmod, and symlink wrappers. >> >> It also adds a wrapper for fgetname() which will be exposed on the >> next patch. >> >> The next patch will be to remove the thread context from the >> parameters of the wrapper routines and the internal routines where it >> is no longer needed. >> >> -John >> [email protected] >> Personal Opinion Only >> --- /ref1_root/perl/vms/vms.c Sun Feb 1 23:43:05 2009 >> +++ vms/vms.c Tue Feb 3 22:52:07 2009 > > patch is not happy with this patch: > > $ gpatch --dry-run -p0 -l --fuzz 10 -i chdir_chmod_mkdir.eml > patching file vms/vms.c > Hunk #10 FAILED at 5271. > Hunk #11 FAILED at 5327. > Hunk #12 FAILED at 5369. > Hunk #13 FAILED at 5380. > Hunk #14 FAILED at 5392. > Hunk #15 FAILED at 5408. > Hunk #16 FAILED at 5420. > Hunk #17 FAILED at 5435. > Hunk #18 FAILED at 5498. > Hunk #19 FAILED at 5510. > Hunk #20 succeeded at 9436 (offset 28 lines). > Hunk #22 succeeded at 12993 (offset 229 lines). > Hunk #23 succeeded at 12965 with fuzz 3. > Hunk #24 succeeded at 14020 (offset 28 lines). > Hunk #26 succeeded at 14100 (offset 28 lines). > Hunk #28 succeeded at 14341 (offset 28 lines). > 10 out of 29 hunks FAILED -- saving rejects to file vms/vms.c.rej > > >> @@ -283,8 +283,6 @@ >> #define do_tovmsspec(a,b,c,d) mp_do_tovmsspec(aTHX_ a,b,c,0,d) >> #define do_tovmspath(a,b,c,d) mp_do_tovmspath(aTHX_ a,b,c,d) >> #define do_rmsexpand(a,b,c,d,e,f,g) mp_do_rmsexpand(aTHX_ >> a,b,c,d,e,f,g) >> -#define do_vms_realpath(a,b,c) mp_do_vms_realpath(aTHX_ a,b,c) >> -#define do_vms_realname(a,b,c) mp_do_vms_realname(aTHX_ a,b,c) >> #define do_tounixspec(a,b,c,d) mp_do_tounixspec(aTHX_ a,b,c,d) >> #define do_tounixpath(a,b,c,d) mp_do_tounixpath(aTHX_ a,b,c,d) >> #define do_vms_case_tolerant(a) mp_do_vms_case_tolerant(a) >> @@ -2213,10 +2211,16 @@ >> * so we'll allow it for a gain in portability. >> */ >> if (dir[dirlen-1] == '/') { >> - char *newdir = savepvn(dir,dirlen-1); >> - int ret = mkdir(newdir,mode); >> - Safefree(newdir); >> - return ret; >> + char *newdir; >> + int ret; >> + newdir = PerlMem_malloc(dirlen); >> + if (newdir ==NULL) >> + _ckvmssts_noperl(SS$_INSFMEM); >> + strncpy(newdir, dir, dirlen - 1); >> + newdir[dirlen-1] = '\0'; >> + ret = mkdir(newdir, mode); >> + PerlMem_free(newdir); >> + return ret; >> } >> else return mkdir(dir,mode); >> } /* end of my_mkdir */ >> @@ -2250,10 +2254,16 @@ >> * - Preview- '/' will be valid soon on VMS >> */ >> if ((dirlen > 1) && (dir1[dirlen-1] == '/')) { >> - char *newdir = savepvn(dir1,dirlen-1); >> - int ret = chdir(newdir); >> - Safefree(newdir); >> - return ret; >> + char *newdir; >> + int ret; >> + newdir = PerlMem_malloc(dirlen); >> + if (newdir ==NULL) >> + _ckvmssts_noperl(SS$_INSFMEM); >> + strncpy(newdir, dir1, dirlen-1); >> + newdir[dirlen-1] = '\0'; >> + ret = chdir(newdir); >> + PerlMem_free(newdir); >> + return ret; >> } >> else return chdir(dir1); >> } /* end of my_chdir */ >> @@ -2264,6 +2274,9 @@ >> int >> Perl_my_chmod(pTHX_ const char *file_spec, mode_t mode) >> { >> + Stat_t st; >> + int ret = -1; >> + char * changefile; >> STRLEN speclen = strlen(file_spec); >> >> /* zero length string sometimes gives ACCVIO */ >> @@ -2276,41 +2289,26 @@ >> * Tests are showing that chmod() on VMS 8.3 is only accepting >> directories >> * in VMS file.dir notation. >> */ >> - if ((speclen > 1) && (file_spec[speclen-1] == '/')) { >> - char *vms_src, *vms_dir, *rslt; >> - int ret = -1; >> - errno = EIO; >> - >> - /* First convert this to a VMS format specification */ >> - vms_src = PerlMem_malloc(VMS_MAXRSS); >> - if (vms_src == NULL) >> - _ckvmssts_noperl(SS$_INSFMEM); >> + changefile = (char *) file_spec; /* cast ok */ >> + ret = Perl_flex_lstat(NULL, file_spec, &st); > > You're explicitly passing a null thread context? That won't work. The > function prototype is > > int Perl_flex_lstat (pTHX_ const char *, Stat_t *); > > and pTHX_ will not expand to anything in the case of a Perl built > without thread support. So in a non-threaded Perl you'll be passing > three arguments to a function that expects two. What problem are you > trying to solve by ignoring whatever actual thread context there may be > and saying that it's always null? The next patch would have covered that as would remove the thread context from the wrappers and static routines that do not need it. I do not know why the patch would not apply though. I will revise and resubmit with the changes to vmsish.h to remove the thread context. It will probably take a few days. Thanks, -John [email protected] Personal Opinion Only