summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_files.c33
-rw-r--r--src/os/unix/ngx_files.h1
2 files changed, 34 insertions, 0 deletions
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index 7e8e58fe7..1c82a8ead 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -884,6 +884,19 @@ ngx_fs_bsize(u_char *name)
return (size_t) fs.f_bsize;
}
+
+off_t
+ngx_fs_available(u_char *name)
+{
+ struct statfs fs;
+
+ if (statfs((char *) name, &fs) == -1) {
+ return NGX_MAX_OFF_T_VALUE;
+ }
+
+ return (off_t) fs.f_bavail * fs.f_bsize;
+}
+
#elif (NGX_HAVE_STATVFS)
size_t
@@ -908,6 +921,19 @@ ngx_fs_bsize(u_char *name)
return (size_t) fs.f_frsize;
}
+
+off_t
+ngx_fs_available(u_char *name)
+{
+ struct statvfs fs;
+
+ if (statvfs((char *) name, &fs) == -1) {
+ return NGX_MAX_OFF_T_VALUE;
+ }
+
+ return (off_t) fs.f_bavail * fs.f_frsize;
+}
+
#else
size_t
@@ -916,4 +942,11 @@ ngx_fs_bsize(u_char *name)
return 512;
}
+
+off_t
+ngx_fs_available(u_char *name)
+{
+ return NGX_MAX_OFF_T_VALUE;
+}
+
#endif
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 3e36984b9..d084713b6 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -349,6 +349,7 @@ ngx_int_t ngx_directio_off(ngx_fd_t fd);
#endif
size_t ngx_fs_bsize(u_char *name);
+off_t ngx_fs_available(u_char *name);
#if (NGX_HAVE_OPENAT)