[PATCH 11 of 12] Win32: fixed ngx_fs_bsize() for symlinks

Maxim Dounin mdounin at mdounin.ru
Thu Jan 12 21:35:34 UTC 2023


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1673549010 -10800
#      Thu Jan 12 21:43:30 2023 +0300
# Node ID be7eb9ec28dcbfdfd2e850befc8d051c0e4d46fd
# Parent  e62c8e9724ba68a698a2c3613edca73fe4e1c4ae
Win32: fixed ngx_fs_bsize() for symlinks.

Just a drive letter might not correctly represent file system being used,
notably when using symlinks (as created by "mklink /d").  As such, instead
of calling GetDiskFreeSpace() with just a drive letter, we now always
use GetDiskFreeSpace() with full path.

diff -r e62c8e9724ba -r be7eb9ec28dc src/os/win32/ngx_files.c
--- a/src/os/win32/ngx_files.c	Thu Jan 12 21:43:14 2023 +0300
+++ b/src/os/win32/ngx_files.c	Thu Jan 12 21:43:30 2023 +0300
@@ -955,14 +955,8 @@ ngx_directio_off(ngx_fd_t fd)
 size_t
 ngx_fs_bsize(u_char *name)
 {
-    u_char  root[4];
     u_long  sc, bs, nfree, ncl;
 
-    if (name[2] == ':') {
-        ngx_cpystrn(root, name, 4);
-        name = root;
-    }
-
     if (GetDiskFreeSpace((const char *) name, &sc, &bs, &nfree, &ncl) == 0) {
         return 512;
     }


More information about the nginx-devel mailing list