diff options
author | Jeremy Allison <jra@samba.org> | 2000-01-06 01:41:27 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-01-06 01:41:27 +0000 |
commit | 8bd94c178ff108bbc6e686e33b99588876ab8a5a (patch) | |
tree | 84f04dbc9bef5f7a85685ba5019440d2163babbb /source3/smbd | |
parent | eb87c3fbdc83839ff7a0e4d3911d46b1d994d545 (diff) | |
download | samba-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/smbd')
-rw-r--r-- | source3/smbd/dfree.c | 49 |
1 files changed, 48 insertions, 1 deletions
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; |