From 7f4774ae47f6628888c2da9409229189fba57844 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Tue, 10 Aug 1999 14:11:15 +0000 Subject: [PATCH] Use Mode_t. p4raw-id: //depot/cfgperl@3949 --- doio.c | 17 +++++++++-------- embed.pl | 4 ++-- perlapi.c | 6 +++--- pp_sys.c | 4 ++-- proto.h | 4 ++-- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/doio.c b/doio.c index 7620e3a..838d67f 100644 --- a/doio.c +++ b/doio.c @@ -1487,9 +1487,10 @@ nothing in the core. /* Do the permissions allow some operation? Assumes statcache already set. */ #ifndef VMS /* VMS' cando is in vms.c */ -I32 -Perl_cando(pTHX_ I32 bit, Uid_t effective, register struct stat *statbufp) -/* Note: we use `effective' both for uids and gids. */ +bool +Perl_cando(pTHX_ Mode_t mode, Uid_t effective, register Stat_t *statbufp) +/* Note: we use `effective' both for uids and gids. + * Here we are betting on Uid_t being equal or wider than Gid_t. */ { #ifdef DOSISH /* [Comments and code from Len Reed] @@ -1513,11 +1514,11 @@ Perl_cando(pTHX_ I32 bit, Uid_t effective, register struct stat *statbufp) /* Atari stat() does pretty much the same thing. we set x_bit_set_in_stat * too so it will actually look into the files for magic numbers */ - return (bit & statbufp->st_mode) ? TRUE : FALSE; + return (mode & statbufp->st_mode) ? TRUE : FALSE; #else /* ! DOSISH */ if ((effective ? PL_euid : PL_uid) == 0) { /* root is special */ - if (bit == S_IXUSR) { + if (mode == S_IXUSR) { if (statbufp->st_mode & 0111 || S_ISDIR(statbufp->st_mode)) return TRUE; } @@ -1526,14 +1527,14 @@ Perl_cando(pTHX_ I32 bit, Uid_t effective, register struct stat *statbufp) return FALSE; } if (statbufp->st_uid == (effective ? PL_euid : PL_uid) ) { - if (statbufp->st_mode & bit) + if (statbufp->st_mode & mode) return TRUE; /* ok as "user" */ } else if (ingroup(statbufp->st_gid,effective)) { - if (statbufp->st_mode & bit >> 3) + if (statbufp->st_mode & mode >> 3) return TRUE; /* ok as "group" */ } - else if (statbufp->st_mode & bit >> 6) + else if (statbufp->st_mode & mode >> 6) return TRUE; /* ok as "other" */ return FALSE; #endif /* ! DOSISH */ diff --git a/embed.pl b/embed.pl index ff4ad5c..cd3b578 100755 --- a/embed.pl +++ b/embed.pl @@ -1051,7 +1051,7 @@ p |I32 |block_gimme p |int |block_start |int full p |void |boot_core_UNIVERSAL p |void |call_list |I32 oldscope|AV* av_list -p |I32 |cando |I32 bit|Uid_t effective|Stat_t* statbufp +p |bool |cando |Mode_t mode|Uid_t effective|Stat_t* statbufp p |U32 |cast_ulong |NV f p |I32 |cast_i32 |NV f p |IV |cast_iv |NV f @@ -1909,7 +1909,7 @@ s |SV* |method_common |SV* meth|U32* hashp #if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT) s |OP* |doform |CV *cv|GV *gv|OP *retop -s |int |emulate_eaccess|const char* path|int mode +s |int |emulate_eaccess|const char* path|Mode_t mode # if !defined(HAS_MKDIR) || !defined(HAS_RMDIR) s |int |dooneliner |char *cmd|char *filename # endif diff --git a/perlapi.c b/perlapi.c index 4875caa..05681a5 100755 --- a/perlapi.c +++ b/perlapi.c @@ -253,10 +253,10 @@ Perl_call_list(pTHXo_ I32 oldscope, AV* av_list) } #undef Perl_cando -I32 -Perl_cando(pTHXo_ I32 bit, Uid_t effective, Stat_t* statbufp) +bool +Perl_cando(pTHXo_ Mode_t mode, Uid_t effective, Stat_t* statbufp) { - return ((CPerlObj*)pPerl)->Perl_cando(bit, effective, statbufp); + return ((CPerlObj*)pPerl)->Perl_cando(mode, effective, statbufp); } #undef Perl_cast_ulong diff --git a/pp_sys.c b/pp_sys.c index 3983619..f469ed0 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -230,7 +230,7 @@ static char zero_but_true[ZBTLEN + 1] = "0 but true"; || defined(HAS_SETREGID) || defined(HAS_SETRESGID)) /* The Hard Way. */ STATIC int -S_emulate_eaccess(pTHX_ const char* path, int mode) +S_emulate_eaccess(pTHX_ const char* path, Mode_t mode) { Uid_t ruid = getuid(); Uid_t euid = geteuid(); @@ -295,7 +295,7 @@ S_emulate_eaccess(pTHX_ const char* path, int mode) #if !defined(PERL_EFF_ACCESS_R_OK) STATIC int -S_emulate_eaccess(pTHX_ const char* path, int mode) +S_emulate_eaccess(pTHX_ const char* path, Mode_t mode) { Perl_croak(aTHX_ "switching effective uid is not implemented"); /*NOTREACHED*/ diff --git a/proto.h b/proto.h index f809677..e10ef7e 100644 --- a/proto.h +++ b/proto.h @@ -37,7 +37,7 @@ VIRTUAL I32 Perl_block_gimme(pTHX); VIRTUAL int Perl_block_start(pTHX_ int full); VIRTUAL void Perl_boot_core_UNIVERSAL(pTHX); VIRTUAL void Perl_call_list(pTHX_ I32 oldscope, AV* av_list); -VIRTUAL I32 Perl_cando(pTHX_ I32 bit, Uid_t effective, Stat_t* statbufp); +VIRTUAL bool Perl_cando(pTHX_ Mode_t mode, Uid_t effective, Stat_t* statbufp); VIRTUAL U32 Perl_cast_ulong(pTHX_ NV f); VIRTUAL I32 Perl_cast_i32(pTHX_ NV f); VIRTUAL IV Perl_cast_iv(pTHX_ NV f); @@ -845,7 +845,7 @@ STATIC SV* S_method_common(pTHX_ SV* meth, U32* hashp); #endif #if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT) STATIC OP* S_doform(pTHX_ CV *cv, GV *gv, OP *retop); -STATIC int S_emulate_eaccess(pTHX_ const char* path, int mode); +STATIC int S_emulate_eaccess(pTHX_ const char* path, Mode_t mode); # if !defined(HAS_MKDIR) || !defined(HAS_RMDIR) STATIC int S_dooneliner(pTHX_ char *cmd, char *filename); # endif -- 1.8.3.1