Welcome! Log In Create A New Profile

Advanced

[PATCH] implemented hardlink option in DAV module

October 15, 2012 07:42AM
Модуль WebDAV на текущий момент не поддерживает хардлинки.
Я реализовал эту поддержку, патч прилагается. Буду очень признателен,
если патч будет включен в следующие версии nginx.

Добавлена директива 'hardlink on|off', по умолчанию off.
Когда опция включена, делается попытка создать хардлинк при копировании
файла. В случае ошибки выполняется обычное копирование.

Роман Арутюнян

---
src/http/modules/ngx_http_dav_module.c | 20 ++++++++++++++++++++
src/os/unix/ngx_files.h | 4 ++++
2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index dbb17ac..e9e0623 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -25,6 +25,7 @@ typedef struct {
ngx_uint_t access;
ngx_uint_t min_delete_depth;
ngx_flag_t create_full_put_path;
+ ngx_flag_t hardlink;
} ngx_http_dav_loc_conf_t;


@@ -106,6 +107,13 @@ static ngx_command_t ngx_http_dav_commands[] = {
offsetof(ngx_http_dav_loc_conf_t, access),
NULL },

+ { ngx_string("hardlink"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_dav_loc_conf_t, hardlink),
+ NULL },
+
ngx_null_command
};

@@ -813,6 +821,15 @@ overwrite_done:

dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);

+ if (dlcf->hardlink) {
+ if (ngx_hardlink_file(path.data, copy.path.data) == NGX_OK) {
+ return NGX_HTTP_NO_CONTENT;
+ }
+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, ngx_errno,
+ "hardlink error: \"%s\"", copy.path.data);
+ }
+
cf.size = ngx_file_size(&fi);
cf.buf_size = 0;
cf.access = dlcf->access;
@@ -1096,6 +1113,7 @@ ngx_http_dav_create_loc_conf(ngx_conf_t *cf)
conf->min_delete_depth = NGX_CONF_UNSET_UINT;
conf->access = NGX_CONF_UNSET_UINT;
conf->create_full_put_path = NGX_CONF_UNSET;
+ conf->hardlink = NGX_CONF_UNSET;

return conf;
}
@@ -1118,6 +1136,8 @@ ngx_http_dav_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->create_full_put_path,
prev->create_full_put_path, 0);

+ ngx_conf_merge_value(conf->hardlink, prev->hardlink, 0);
+
return NGX_CONF_OK;
}

diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 9c97e2b..826960b 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -157,6 +157,10 @@ ngx_write_fd(ngx_fd_t fd, void *buf, size_t n)
#define ngx_rename_file_n "rename()"


+#define ngx_hardlink_file(o, n) link((const char *) o, (const char *) n)
+#define ngx_hardlink_file_n "link()"
+
+
#define ngx_change_file_access(n, a) chmod((const char *) n, a)
#define ngx_change_file_access_n "chmod()"

--
1.7.1

_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

[PATCH] implemented hardlink option in DAV module

arut October 15, 2012 07:42AM

Re: [PATCH] implemented hardlink option in DAV module

kav October 15, 2012 07:48AM

Re: [PATCH] implemented hardlink option in DAV module

arut October 15, 2012 07:58AM

Re: [PATCH] implemented hardlink option in DAV module

kav October 15, 2012 08:04AM

Re: [PATCH] implemented hardlink option in DAV module

arut October 15, 2012 08:10AM

Re: [PATCH] implemented hardlink option in DAV module

kav October 15, 2012 08:24AM

Re: [PATCH] implemented hardlink option in DAV module

Maxim Dounin October 15, 2012 11:34AM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв October 15, 2012 03:32PM

Re: [PATCH] implemented hardlink option in DAV module

Gena Makhomed October 15, 2012 03:58PM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв October 15, 2012 04:16PM

Re: [PATCH] implemented hardlink option in DAV module

Maxim Dounin October 16, 2012 06:18AM

Re: [PATCH] implemented hardlink option in DAV module

Maxim Dounin October 16, 2012 01:12PM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв October 16, 2012 01:32PM

Re: [PATCH] implemented hardlink option in DAV module

Maxim Dounin October 16, 2012 01:50PM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв October 16, 2012 02:06PM

Re: [PATCH] implemented hardlink option in DAV module

Maxim Dounin October 16, 2012 02:36PM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв October 16, 2012 03:04PM

Re: [PATCH] implemented hardlink option in DAV module

kav October 17, 2012 01:34AM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв October 17, 2012 05:28AM

Re: [PATCH] implemented hardlink option in DAV module

kav October 17, 2012 06:02AM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв January 14, 2014 12:34PM

Re: [PATCH] implemented hardlink option in DAV module

Maxim Dounin January 15, 2014 11:40AM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв January 15, 2014 01:18PM

Re: [PATCH] implemented hardlink option in DAV module

Валентин Бартенев January 15, 2014 02:12PM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв October 16, 2012 01:18PM

Re: [PATCH] implemented hardlink option in DAV module

Maxim Dounin October 16, 2012 01:38PM

Re[2]: [PATCH] implemented hardlink option in DAV module

Михаил Монашёв October 16, 2012 01:54PM

Re: [PATCH] implemented hardlink option in DAV module

Maxim Dounin October 16, 2012 02:06PM

Re: [PATCH] implemented hardlink option in DAV module

arut October 16, 2012 08:44AM

[PATCH] implemented DAV copy hardlinks

arut October 16, 2012 08:54AM

Re: [PATCH] implemented DAV copy hardlinks

Gena Makhomed October 16, 2012 11:42AM

Re[2]: [PATCH] implemented DAV copy hardlinks

Михаил Монашёв October 16, 2012 12:50PM

Re: [PATCH] implemented DAV copy hardlinks

arut October 16, 2012 01:08PM

Re: [PATCH] implemented DAV copy hardlinks

Maxim Dounin October 16, 2012 11:46AM

Re: [PATCH] implemented DAV copy hardlinks

arut October 19, 2012 03:22AM

Re: [PATCH] implemented DAV copy hardlinks

Maxim Dounin October 24, 2012 02:04PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready