summaryrefslogtreecommitdiff
path: root/source3/smbd/dfree.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-04-16 11:00:21 +0000
committerAndrew Tridgell <tridge@samba.org>2000-04-16 11:00:21 +0000
commit19f946ba6fe442544ac9b0f71bcd33112fc79995 (patch)
tree1f26158879ef7eba4670d0811871077e921dc65b /source3/smbd/dfree.c
parent83170b36c5511b000e36ad0d3a1d9b73a73d2046 (diff)
downloadsamba-19f946ba6fe442544ac9b0f71bcd33112fc79995.tar.gz
samba-19f946ba6fe442544ac9b0f71bcd33112fc79995.tar.bz2
samba-19f946ba6fe442544ac9b0f71bcd33112fc79995.zip
converted a bunch more functions to use a fd instead of a FILE*
to support some of this I added the following functions in util_file.c file_lines_pload : load lines from a pipe file_pload : load a pipe into memory (This used to be commit a09470817c5b21dba42f9ef4ce5e8b768a254c0b)
Diffstat (limited to 'source3/smbd/dfree.c')
-rw-r--r--source3/smbd/dfree.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
index 0a892bad05..eff718b148 100644
--- a/source3/smbd/dfree.c
+++ b/source3/smbd/dfree.c
@@ -203,24 +203,22 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
(*dfree) = (*dsize) = 0;
(*bsize) = 512;
-
/*
* If external disk calculation specified, use it.
*/
dfree_command = lp_dfree_command();
if (dfree_command && *dfree_command) {
- pstring line;
char *p;
- FILE *pp;
+ char **lines;
+ pstring syscmd;
- slprintf (line, sizeof(pstring) - 1, "%s %s", dfree_command, path);
- DEBUG (3, ("disk_free: Running command %s\n", line));
+ slprintf(syscmd, sizeof(syscmd), "%s %s", dfree_command, path);
+ DEBUG (3, ("disk_free: Running command %s\n", syscmd));
- pp = sys_popen(line, "r", False);
- if (pp) {
- fgets(line, sizeof(pstring), pp);
- line[sizeof(pstring)-1] = '\0';
+ lines = file_lines_pload(syscmd, NULL);
+ if (lines) {
+ char *line = lines[0];
if (strlen(line) > 0)
line[strlen(line)-1] = '\0';
@@ -237,7 +235,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
*bsize = (SMB_BIG_UINT)strtoul(p, NULL, 10);
else
*bsize = 1024;
- sys_pclose (pp);
+ file_lines_free(lines);
DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n",
(unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize));
@@ -247,7 +245,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
*dfree = 1024;
} else {
DEBUG (0, ("disk_free: sys_popen() failed for command %s. Error was : %s\n",
- line, strerror(errno) ));
+ syscmd, strerror(errno) ));
fsusage(path, dfree, dsize);
}
} else