s3-smbd: Leave sys_disk_free() if dfree command is used
authorAndreas Schneider <asn@samba.org>
Fri, 17 Jul 2015 07:35:11 +0000 (09:35 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 17 Jul 2015 17:07:23 +0000 (19:07 +0200)
If we have a broken system which reports incorrect sizes we provide the
'dfree command'. This command makes sure Samba gets the correct values.
However after that we call the quota command which then reports the
broken values. The dfree command should take care to provide the correct
values and in case of quota's it should also calculate the quote
correctly.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11403

Pair-Programmed-With: Michael Adam <obnox@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/dfree.c

index bcefea5b274648ddd29bc45a9fd8a270eff05cf7..12578407ce9246840eac0b8287de6289ae860c33 100644 (file)
@@ -83,7 +83,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
                DEBUG (3, ("disk_free: Running command '%s'\n", syscmd));
 
                lines = file_lines_pload(syscmd, NULL);
-               if (lines) {
+               if (lines != NULL) {
                        char *line = lines[0];
 
                        DEBUG (3, ("Read input from dfree, \"%s\"\n", line));
@@ -107,22 +107,18 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
                                *dsize = 2048;
                        if (!*dfree)
                                *dfree = 1024;
-               } else {
-                       DEBUG (0, ("disk_free: file_lines_load() failed for "
-                                  "command '%s'. Error was : %s\n",
-                                  syscmd, strerror(errno) ));
-                       if (sys_fsusage(path, dfree, dsize) != 0) {
-                               DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n",
-                                       strerror(errno) ));
-                               return (uint64_t)-1;
-                       }
-               }
-       } else {
-               if (sys_fsusage(path, dfree, dsize) != 0) {
-                       DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n",
-                               strerror(errno) ));
-                       return (uint64_t)-1;
+
+                       goto dfree_done;
                }
+               DEBUG (0, ("disk_free: file_lines_load() failed for "
+                          "command '%s'. Error was : %s\n",
+                          syscmd, strerror(errno) ));
+       }
+
+       if (sys_fsusage(path, dfree, dsize) != 0) {
+               DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n",
+                       strerror(errno) ));
+               return (uint64_t)-1;
        }
 
        if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) {
@@ -146,6 +142,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
                *dfree = MAX(1,*dfree);
        }
 
+dfree_done:
        disk_norm(bsize, dfree, dsize);
 
        if ((*bsize) < 1024) {