wrowe 01/11/26 19:08:58
Modified: include/arch/win32 fileio.h misc.h
file_io/win32 dir.c filestat.c
Log:
Optimize the win32 code with the (apr-internal) global apr_os_level,
and clean out an unneeded thunk (since all GetEffectiveRightsFromAcl
calls are by SID, we can always use the W version, peeling away the
A->W thunk in the WinNT kernel.)
Revision Changes Path
1.61 +1 -2 apr/include/arch/win32/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/fileio.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- fileio.h 2001/11/27 02:39:19 1.60
+++ fileio.h 2001/11/27 03:08:58 1.61
@@ -160,8 +160,7 @@
/* Private function that extends apr_stat/lstat/getfileinfo/dir_read */
apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile,
- apr_int32_t wanted, int whatfile,
- apr_oslevel_e os_level);
+ apr_int32_t wanted, int whatfile);
/* whatfile types for the ufile arg */
#define MORE_OF_HANDLE 0
1.34 +0 -9 apr/include/arch/win32/misc.h
Index: misc.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/misc.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- misc.h 2001/11/27 02:31:55 1.33
+++ misc.h 2001/11/27 03:08:58 1.34
@@ -195,15 +195,6 @@
());
#define SwitchToThread apr_winapi_SwitchToThread
-#undef GetEffectiveRightsFromAcl
-APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI,
GetEffectiveRightsFromAclA, 0, (
- IN PACL pacl,
- IN PTRUSTEE_A pTrustee,
- OUT PACCESS_MASK pAccessRights),
- (pacl, pTrustee, pAccessRights));
-#define GetEffectiveRightsFromAclA apr_winapi_GetEffectiveRightsFromAclA
-#define GetEffectiveRightsFromAcl apr_winapi_GetEffectiveRightsFromAclA
-
APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI,
GetEffectiveRightsFromAclW, 0, (
IN PACL pacl,
IN PTRUSTEE_W pTrustee,
1.61 +7 -13 apr/file_io/win32/dir.c
Index: dir.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/dir.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- dir.c 2001/11/12 16:58:37 1.60
+++ dir.c 2001/11/27 03:08:58 1.61
@@ -86,9 +86,6 @@
APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname,
apr_pool_t *cont)
{
-#if APR_HAS_UNICODE_FS
- apr_oslevel_e os_level;
-#endif
int len = strlen(dirname);
(*new) = apr_pcalloc(cont, sizeof(apr_dir_t));
/* Leave room here to add and pop the '*' wildcard for FindFirstFile
@@ -103,7 +100,7 @@
(*new)->dirname[len] = '\0';
#if APR_HAS_UNICODE_FS
- if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
+ if (apr_os_level >= APR_WIN_NT)
{
/* Create a buffer for the longest file name we will ever see
*/
@@ -148,10 +145,9 @@
* we aren't reporting any files where their absolute paths are too long.
*/
#if APR_HAS_UNICODE_FS
- apr_oslevel_e os_level;
apr_wchar_t wdirname[APR_PATH_MAX];
apr_wchar_t *eos = NULL;
- if (!apr_get_oslevel(thedir->cntxt, &os_level) && os_level >= APR_WIN_NT)
+ if (apr_os_level >= APR_WIN_NT)
{
if (thedir->dirhand == INVALID_HANDLE_VALUE)
{
@@ -224,14 +220,14 @@
/* Go back and get more_info if we can't answer the whole inquiry
*/
#if APR_HAS_UNICODE_FS
- if (os_level >= APR_WIN_NT) {
+ if (apr_os_level >= APR_WIN_NT) {
/* Almost all our work is done. Tack on the wide file name
* to the end of the wdirname (already / delimited)
*/
if (!eos)
eos = wcschr(wdirname, '\0');
wcscpy(eos, thedir->w.entry->cFileName);
- rv = more_finfo(finfo, wdirname, wanted, MORE_OF_WFSPEC,
os_level);
+ rv = more_finfo(finfo, wdirname, wanted, MORE_OF_WFSPEC);
eos[0] = '\0';
return rv;
}
@@ -249,7 +245,7 @@
dirlen = sizeof(fspec) - 1;
apr_cpystrn(fspec, thedir->dirname, sizeof(fspec));
apr_cpystrn(fspec + dirlen, fname, sizeof(fspec) - dirlen);
- return more_finfo(finfo, fspec, wanted, MORE_OF_FSPEC, os_level);
+ return more_finfo(finfo, fspec, wanted, MORE_OF_FSPEC);
}
}
@@ -268,8 +264,7 @@
apr_pool_t *cont)
{
#if APR_HAS_UNICODE_FS
- apr_oslevel_e os_level;
- if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
+ if (apr_os_level >= APR_WIN_NT)
{
apr_wchar_t wpath[APR_PATH_MAX];
apr_status_t rv;
@@ -292,8 +287,7 @@
APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *cont)
{
#if APR_HAS_UNICODE_FS
- apr_oslevel_e os_level;
- if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
+ if (apr_os_level >= APR_WIN_NT)
{
apr_wchar_t wpath[APR_PATH_MAX];
apr_status_t rv;
1.58 +29 -22 apr/file_io/win32/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/filestat.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- filestat.c 2001/11/12 16:58:37 1.57
+++ filestat.c 2001/11/27 03:08:58 1.58
@@ -105,8 +105,12 @@
static void resolve_prot(apr_finfo_t *finfo, apr_int32_t wanted, PACL dacl)
{
- TRUSTEE ident = {NULL, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_SID};
+ TRUSTEE_W ident = {NULL, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_SID};
ACCESS_MASK acc;
+ /*
+ * This function is only invoked for WinNT,
+ * there is no reason for os_level testing here.
+ */
if ((wanted & APR_FINFO_WPROT) && !worldid) {
SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_WORLD_SID_AUTHORITY;
if (AllocateAndInitializeSid(&SIDAuth, 1, SECURITY_WORLD_RID,
@@ -118,15 +122,24 @@
if ((wanted & APR_FINFO_UPROT) && (finfo->valid & APR_FINFO_USER)) {
ident.TrusteeType = TRUSTEE_IS_USER;
ident.ptstrName = finfo->user;
- if (GetEffectiveRightsFromAcl(dacl, &ident, &acc) == ERROR_SUCCESS) {
+ /* GetEffectiveRightsFromAcl isn't supported under Win9x,
+ * which shouldn't come as a surprize. Since we are passing
+ * TRUSTEE_IS_SID, always skip the A->W layer.
+ */
+ if (GetEffectiveRightsFromAclW(dacl, &ident, &acc) == ERROR_SUCCESS)
{
finfo->protection |= convert_prot(acc, prot_scope_user);
finfo->valid |= APR_FINFO_UPROT;
}
}
+ /* Windows NT: did not return group rights.
+ * Windows 2000 returns group rights information.
+ * Since WinNT kernels don't follow the unix model of
+ * group associations, this all all pretty mute.
+ */
if ((wanted & APR_FINFO_GPROT) && (finfo->valid & APR_FINFO_GROUP)) {
ident.TrusteeType = TRUSTEE_IS_GROUP;
ident.ptstrName = finfo->group;
- if (GetEffectiveRightsFromAcl(dacl, &ident, &acc) == ERROR_SUCCESS) {
+ if (GetEffectiveRightsFromAclW(dacl, &ident, &acc) == ERROR_SUCCESS)
{
finfo->protection |= convert_prot(acc, prot_scope_group);
finfo->valid |= APR_FINFO_GPROT;
}
@@ -134,7 +147,7 @@
if ((wanted & APR_FINFO_WPROT) && (worldid)) {
ident.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
ident.ptstrName = worldid;
- if (GetEffectiveRightsFromAcl(dacl, &ident, &acc) == ERROR_SUCCESS) {
+ if (GetEffectiveRightsFromAclW(dacl, &ident, &acc) == ERROR_SUCCESS)
{
finfo->protection |= convert_prot(acc, prot_scope_world);
finfo->valid |= APR_FINFO_WPROT;
}
@@ -190,14 +203,14 @@
return rv;
}
-apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, apr_int32_t
wanted,
- int whatfile, apr_oslevel_e os_level)
+apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile,
+ apr_int32_t wanted, int whatfile)
{
PSID user = NULL, grp = NULL;
PACL dacl = NULL;
apr_status_t rv;
- if (os_level < APR_WIN_NT)
+ if (apr_os_level < APR_WIN_NT)
{
/* Read, write execute for owner. In the Win9x environment, any
* readable file is executable (well, not entirely 100% true, but
@@ -404,10 +417,7 @@
/* If we still want something more (besides the name) go get it!
*/
if ((wanted &= ~finfo->valid) & ~APR_FINFO_NAME) {
- apr_oslevel_e os_level;
- if (apr_get_oslevel(thefile->cntxt, &os_level))
- os_level = APR_WIN_95;
- return more_finfo(finfo, thefile->filehand, wanted, MORE_OF_HANDLE,
os_level);
+ return more_finfo(finfo, thefile->filehand, wanted, MORE_OF_HANDLE);
}
return APR_SUCCESS;
@@ -430,7 +440,6 @@
apr_wchar_t wfname[APR_PATH_MAX];
#endif
- apr_oslevel_e os_level;
char *filename = NULL;
/* These all share a common subset of this structure */
union {
@@ -439,9 +448,6 @@
WIN32_FILE_ATTRIBUTE_DATA i;
} FileInfo;
- if (apr_get_oslevel(cont, &os_level))
- os_level = APR_WIN_95;
-
/* Catch fname length == MAX_PATH since GetFileAttributesEx fails
* with PATH_NOT_FOUND. We would rather indicate length error than
* 'not found'
@@ -450,7 +456,7 @@
return APR_ENAMETOOLONG;
}
- if ((os_level >= APR_WIN_NT)
+ if ((apr_os_level >= APR_WIN_NT)
&& (wanted & (APR_FINFO_IDENT | APR_FINFO_NLINK))) {
/* FindFirstFile and GetFileAttributesEx can't figure the inode,
* device or number of links, so we need to resolve with an open
@@ -466,7 +472,7 @@
}
#if APR_HAS_UNICODE_FS
- if (os_level >= APR_WIN_NT) {
+ if (apr_os_level >= APR_WIN_NT) {
if (rv = utf8_to_unicode_path(wfname, sizeof(wfname)
/ sizeof(apr_wchar_t), fname))
return rv;
@@ -497,9 +503,10 @@
}
else
#endif
- if ((os_level >= APR_WIN_98) && (!(wanted & APR_FINFO_NAME) || isroot))
+ if ((apr_os_level >= APR_WIN_98) && (!(wanted & APR_FINFO_NAME) ||
isroot))
{
/* cannot use FindFile on a Win98 root, it returns \*
+ * GetFileAttributesExA is not available on Win95
*/
if (!GetFileAttributesExA(fname, GetFileExInfoStandard,
&FileInfo.i)) {
@@ -548,7 +555,7 @@
* to reliably translate char devices to the path '\\.\device'
* so go ask for the full path.
*/
- if (os_level >= APR_WIN_NT) {
+ if (apr_os_level >= APR_WIN_NT) {
#if APR_HAS_UNICODE_FS
apr_wchar_t tmpname[APR_FILE_MAX];
apr_wchar_t *tmpoff;
@@ -582,10 +589,10 @@
if (wanted &= ~finfo->valid) {
/* Caller wants more than APR_FINFO_MIN | APR_FINFO_NAME */
#if APR_HAS_UNICODE_FS
- if (os_level >= APR_WIN_NT)
- return more_finfo(finfo, wfname, wanted, MORE_OF_WFSPEC,
os_level);
+ if (apr_os_level >= APR_WIN_NT)
+ return more_finfo(finfo, wfname, wanted, MORE_OF_WFSPEC);
#endif
- return more_finfo(finfo, fname, wanted, MORE_OF_FSPEC, os_level);
+ return more_finfo(finfo, fname, wanted, MORE_OF_FSPEC);
}
return APR_SUCCESS;