summaryrefslogtreecommitdiff
path: root/sysutils/fusefs-smbnetfs/files/patch-3
blob: 4e609697a0535d6e3255bd9902e2a1c6770e5109 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Part of the:

	https://sourceforge.net/p/smbnetfs/patches/3/

--- src/samba.h	2018-01-04 20:59:38.000000000 +0000
+++ src/samba.h	2018-01-31 14:48:19.375119000 +0000
@@ -16,6 +16,6 @@
 samba_fd samba_open       (const char *url, int flags, mode_t mode);
 samba_fd samba_creat      (const char *url, mode_t mode);
-ssize_t  samba_read       (samba_fd fd, off_t offset, void *buf, size_t bufsize);
-ssize_t  samba_write      (samba_fd fd, off_t offset, void *buf, size_t bufsize);
+ssize_t  samba_read       (samba_fd fd, off_t offset, char *buf, size_t bufsize);
+ssize_t  samba_write      (samba_fd fd, off_t offset, const char *buf, size_t bufsize);
 int      samba_close      (samba_fd fd);
 int      samba_unlink     (const char *url);
--- src/samba.c	2018-01-04 20:59:38.000000000 +0000
+++ src/samba.c	2018-01-31 14:49:26.546183000 +0000
@@ -255,5 +255,5 @@
 }
 
-ssize_t samba_read(samba_fd fd, off_t offset, void *buf, size_t bufsize){
+ssize_t samba_read(samba_fd fd, off_t offset, char *buf, size_t bufsize){
     ssize_t	result = 0;
 
@@ -278,5 +278,5 @@
 }
 
-ssize_t samba_write(samba_fd fd, off_t offset, void *buf, size_t bufsize){
+ssize_t samba_write(samba_fd fd, off_t offset, const char *buf, size_t bufsize){
     ssize_t	result = 0;
 
Constify the writing and reduce the number of calls to time().

	-mi

--- src/smb_conn.h	2018-01-04 20:59:38
+++ src/smb_conn.h	2018-01-31 14:55:24
@@ -46,5 +46,5 @@
 ssize_t smb_conn_write(struct smb_conn_ctx *ctx,
 			smb_conn_fd fd, off_t offset,
-			void *buf, size_t bufsize);
+			const void *buf, size_t bufsize);
 int smb_conn_close(struct smb_conn_ctx *ctx,
 			smb_conn_fd fd);
--- src/smb_conn.c	2018-01-04 20:59:38
+++ src/smb_conn.c	2018-01-31 14:54:37
@@ -630,6 +630,5 @@
 
     pthread_mutex_lock(&ctx->mutex);
-    ctx->access_time = time(NULL);
-    file->access_time = time(NULL);
+    ctx->access_time = file->access_time = time(NULL);
     error = smb_conn_process_query(
 			ctx, OPEN,
@@ -676,6 +675,5 @@
 
     pthread_mutex_lock(&ctx->mutex);
-    ctx->access_time = time(NULL);
-    file->access_time = time(NULL);
+    ctx->access_time = file->access_time = time(NULL);
     error = smb_conn_process_query(
 			ctx, CREAT,
@@ -719,6 +717,5 @@
     pthread_mutex_lock(&ctx->mutex);
     if ((file->reopen_cmd == OPEN) && (file->ctx == ctx)){
-	ctx->access_time = time(NULL);
-	file->access_time = time(NULL);
+	ctx->access_time = file->access_time = time(NULL);
 	error = smb_conn_process_fd_query(
 			ctx, READ, file,
@@ -740,5 +737,5 @@
 ssize_t smb_conn_write(struct smb_conn_ctx *ctx,
 			smb_conn_fd fd, off_t offset,
-			void *buf, size_t bufsize){
+			const void *buf, size_t bufsize){
 
     int					error;
@@ -762,6 +759,5 @@
     pthread_mutex_lock(&ctx->mutex);
     if ((file->reopen_cmd == OPEN) && (file->ctx == ctx)){
-	ctx->access_time = time(NULL);
-	file->access_time = time(NULL);
+	ctx->access_time = file->access_time = time(NULL);
 	memcpy(ctx->shmem_ptr, buf, bufsize);
 	msync(ctx->shmem_ptr, bufsize, MS_SYNC);
@@ -886,6 +882,5 @@
 
     pthread_mutex_lock(&ctx->mutex);
-    ctx->access_time = time(NULL);
-    file->access_time = time(NULL);
+    ctx->access_time = file->access_time = time(NULL);
     error = smb_conn_process_query(
 			ctx, OPENDIR,
@@ -964,6 +959,5 @@
     pthread_mutex_lock(&ctx->mutex);
     if ((file->reopen_cmd == OPENDIR) && (file->ctx == ctx)){
-	ctx->access_time = time(NULL);
-	file->access_time = time(NULL);
+	ctx->access_time = file->access_time = time(NULL);
 
 	/* we cant reopen directory with non-zero offset, so use               */
@@ -1104,6 +1098,5 @@
     pthread_mutex_lock(&ctx->mutex);
     if ((file->reopen_cmd == OPEN) && (file->ctx == ctx)){
-	ctx->access_time = time(NULL);
-	file->access_time = time(NULL);
+	ctx->access_time = file->access_time = time(NULL);
 	error = smb_conn_process_fd_query(
 			ctx, FSTAT, file,
@@ -1141,6 +1134,5 @@
     pthread_mutex_lock(&ctx->mutex);
     if ((file->reopen_cmd == OPEN) && (file->ctx == ctx)){
-	ctx->access_time = time(NULL);
-	file->access_time = time(NULL);
+	ctx->access_time = file->access_time = time(NULL);
 	error = smb_conn_process_fd_query(
 			ctx, FTRUNCATE, file,