1 |
From 80d7fe6f06c820253d0c687153a3c781bc55cb0c Mon Sep 17 00:00:00 2001 |
2 |
From: Andreas Schneider <asn@samba.org> |
3 |
Date: Fri, 17 Jul 2015 09:35:11 +0200 |
4 |
Subject: [PATCH] s3-smbd: Leave sys_disk_free() if dfree command is used |
5 |
|
6 |
If we have a broken system which reports incorrect sizes we provide the |
7 |
'dfree command'. This command makes sure Samba gets the correct values. |
8 |
However after that we call the quota command which then reports the |
9 |
broken values. The dfree command should take care to provide the correct |
10 |
values and in case of quota's it should also calculate the quote |
11 |
correctly. |
12 |
|
13 |
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11403 |
14 |
|
15 |
Pair-Programmed-With: Michael Adam <obnox@samba.org> |
16 |
Signed-off-by: Andreas Schneider <asn@samba.org> |
17 |
Signed-off-by: Michael Adam <obnox@samba.org> |
18 |
Reviewed-by: Ralph Boehme <slow@samba.org> |
19 |
(cherry picked from commit 48a4d5a4078ff2a66dd753323d6e5d76d34b9828) |
20 |
--- |
21 |
source3/smbd/dfree.c | 29 +++++++++++++---------------- |
22 |
1 file changed, 13 insertions(+), 16 deletions(-) |
23 |
|
24 |
diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c |
25 |
index d02c1bd..09b00f4 100644 |
26 |
--- a/source3/smbd/dfree.c |
27 |
+++ b/source3/smbd/dfree.c |
28 |
@@ -98,7 +98,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_que |
29 |
DEBUG (3, ("disk_free: Running command '%s'\n", syscmd)); |
30 |
|
31 |
lines = file_lines_pload(syscmd, NULL); |
32 |
- if (lines) { |
33 |
+ if (lines != NULL) { |
34 |
char *line = lines[0]; |
35 |
|
36 |
DEBUG (3, ("Read input from dfree, \"%s\"\n", line)); |
37 |
@@ -122,22 +122,18 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_que |
38 |
*dsize = 2048; |
39 |
if (!*dfree) |
40 |
*dfree = 1024; |
41 |
- } else { |
42 |
- DEBUG (0, ("disk_free: file_lines_load() failed for " |
43 |
- "command '%s'. Error was : %s\n", |
44 |
- syscmd, strerror(errno) )); |
45 |
- if (sys_fsusage(path, dfree, dsize) != 0) { |
46 |
- DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n", |
47 |
- strerror(errno) )); |
48 |
- return (uint64_t)-1; |
49 |
- } |
50 |
- } |
51 |
- } else { |
52 |
- if (sys_fsusage(path, dfree, dsize) != 0) { |
53 |
- DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n", |
54 |
- strerror(errno) )); |
55 |
- return (uint64_t)-1; |
56 |
+ |
57 |
+ goto dfree_done; |
58 |
} |
59 |
+ DEBUG (0, ("disk_free: file_lines_load() failed for " |
60 |
+ "command '%s'. Error was : %s\n", |
61 |
+ syscmd, strerror(errno) )); |
62 |
+ } |
63 |
+ |
64 |
+ if (sys_fsusage(path, dfree, dsize) != 0) { |
65 |
+ DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n", |
66 |
+ strerror(errno) )); |
67 |
+ return (uint64_t)-1; |
68 |
} |
69 |
|
70 |
if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { |
71 |
@@ -161,6 +157,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_que |
72 |
*dfree = MAX(1,*dfree); |
73 |
} |
74 |
|
75 |
+dfree_done: |
76 |
disk_norm(small_query,bsize,dfree,dsize); |
77 |
|
78 |
if ((*bsize) < 1024) { |
79 |
-- |
80 |
2.4.5 |
81 |
|