From 19f946ba6fe442544ac9b0f71bcd33112fc79995 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Apr 2000 11:00:21 +0000 Subject: 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) --- source3/smbd/dfree.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'source3/smbd/dfree.c') 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 -- cgit