summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-01-06 01:41:27 +0000
committerJeremy Allison <jra@samba.org>2000-01-06 01:41:27 +0000
commit8bd94c178ff108bbc6e686e33b99588876ab8a5a (patch)
tree84f04dbc9bef5f7a85685ba5019440d2163babbb /source3
parenteb87c3fbdc83839ff7a0e4d3911d46b1d994d545 (diff)
downloadsamba-8bd94c178ff108bbc6e686e33b99588876ab8a5a.tar.gz
samba-8bd94c178ff108bbc6e686e33b99588876ab8a5a.tar.bz2
samba-8bd94c178ff108bbc6e686e33b99588876ab8a5a.zip
Re-added "dfree command" functionality that was described in the man pages
but was not in the code. Jeremy. (This used to be commit f4898a1f16a2dbc25d062b0088d6c589a34c93a0)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/param/loadparm.c1
-rw-r--r--source3/smbd/dfree.c49
3 files changed, 50 insertions, 1 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index dd25ae1d79..4354447acd 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1128,6 +1128,7 @@ char *lp_lockdir(void);
char *lp_rootdir(void);
char *lp_defaultservice(void);
char *lp_msg_command(void);
+char *lp_dfree_command(void);
char *lp_hosts_equiv(void);
char *lp_auto_services(void);
char *lp_passwd_program(void);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index b76af54609..e57b5e7d4f 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1165,6 +1165,7 @@ FN_GLOBAL_STRING(lp_lockdir,&Globals.szLockDir)
FN_GLOBAL_STRING(lp_rootdir,&Globals.szRootdir)
FN_GLOBAL_STRING(lp_defaultservice,&Globals.szDefaultService)
FN_GLOBAL_STRING(lp_msg_command,&Globals.szMsgCommand)
+FN_GLOBAL_STRING(lp_dfree_command,&Globals.szDfree)
FN_GLOBAL_STRING(lp_hosts_equiv,&Globals.szHostsEquiv)
FN_GLOBAL_STRING(lp_auto_services,&Globals.szAutoServices)
FN_GLOBAL_STRING(lp_passwd_program,&Globals.szPasswdProgram)
diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
index 86a155f526..ddb91ab498 100644
--- a/source3/smbd/dfree.c
+++ b/source3/smbd/dfree.c
@@ -198,11 +198,58 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
SMB_BIG_UINT dfree_q = 0;
SMB_BIG_UINT bsize_q = 0;
SMB_BIG_UINT dsize_q = 0;
+ char *dfree_command;
(*dfree) = (*dsize) = 0;
(*bsize) = 512;
- fsusage(path, dfree, dsize);
+
+ /*
+ * If external disk calculation specified, use it.
+ */
+
+ dfree_command = lp_dfree_command();
+ if (dfree_command && *dfree_command) {
+ pstring line;
+ char *p;
+ FILE *pp;
+
+ snprintf (line, sizeof(pstring), "%s %s", dfree_command, path);
+ pp = popen(line, "r");
+ if (pp) {
+ fgets(line, sizeof(pstring), pp);
+ line[sizeof(pstring)-1] = '\0';
+ if (strlen(line) > 0)
+ line[strlen(line)-1] = '\0';
+
+ DEBUG (3, ("Read input from dfree, \"%s\"\n", line));
+
+ *dsize = (SMB_BIG_UINT)strtoul(line, &p, 10);
+ while (p && *p & isspace(*p))
+ p++;
+ if (p && *p)
+ *dfree = (SMB_BIG_UINT)strtoul(p, &p, 10);
+ while (p && *p & isspace(*p))
+ p++;
+ if (p && *p)
+ *bsize = (SMB_BIG_UINT)strtoul(p, NULL, 10);
+ else
+ *bsize = 1024;
+ pclose (pp);
+ DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n",
+ (unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize));
+
+ if (!*dsize)
+ *dsize = 2048;
+ if (!*dfree)
+ *dfree = 1024;
+ } else {
+ DEBUG (0, ("disk_free: popen() failed for command %s. Error was : %s\n",
+ line, strerror(errno) ));
+ fsusage(path, dfree, dsize);
+ }
+ } else
+ fsusage(path, dfree, dsize);
if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) {
(*bsize) = bsize_q;