dfree behaviour [Was: Re: Broken "dfree command" in Samba 2.0.5a]
Morgan Hughes
kyhm at mars.ark.com
Thu Dec 23 20:14:55 GMT 1999
On Fri, 24 Dec 1999, Morgan Hughes wrote:
> I ran into something like this a while back, with 2.0.3. I've got a
> patch for 2.0.3 (it complains, but works, with 2.0.5a) which enables
> the functionality. Apparently the "dfree command" parameter is ignored
> if configure finds a reliable system call in the system...
>
> The patch should be applied to as clean a source tree as possible, from
> the root of the tarball (ie, where Manifest and WHATSNEW.txt are)
>
> Hope this helps!
Would help more if I included the patch... D'oh! ;-)
--
Morgan Hughes
C programmer and highly caffeinated mammal
kyhm at email.com
-------------- next part --------------
--- source/param/loadparm.c-orig Tue May 4 10:27:11 1999
+++ source/param/loadparm.c Fri Apr 30 14:59:26 1999
@@ -1109,6 +1109,7 @@
int fn_name(int i) {return(LP_SNUM_OK(i)? pSERVICE(i)->val : sDefault.val);}
FN_GLOBAL_STRING(lp_logfile,&Globals.szLogFile)
+FN_GLOBAL_STRING(lp_dfree_command,&Globals.szDfree)
FN_GLOBAL_STRING(lp_smbrun,&Globals.szSmbrun)
FN_GLOBAL_STRING(lp_configfile,&Globals.szConfigFile)
FN_GLOBAL_STRING(lp_smb_passwd_file,&Globals.szSMBPasswdFile)
--- source/smbd/dfree.c-orig Tue May 4 10:27:37 1999
+++ source/smbd/dfree.c Mon May 3 15:43:41 1999
@@ -82,6 +82,7 @@
*/
static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
+
#ifdef STAT_STATFS3_OSF1
#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_fsize, (SMB_BIG_UINT)512)
struct statfs fsd;
@@ -198,11 +199,49 @@
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);
+ /* hack inserted since support for external disk freespace calculation
+ * (the "dfree command") seems to have vanished. */
+ dfree_command = lp_dfree_command();
+ if (dfree_command && *dfree_command)
+ {
+ char line[256],
+ *p;
+ int adj;
+ FILE *pp;
+
+ snprintf (line, 256, "%s %s", dfree_command, path);
+ pp = popen(line, "r");
+ if (pp)
+ {
+ fgets(line, 256, pp);
+ if (strlen(line) > 0) line[strlen(line)-1] = '\0';
+ DEBUG (3, ("Read input from dfree, \"%s\"\n", line));
+
+ *dsize = strtoul(line, &p, 10);
+ while (p && *p & isspace(*p)) p++;
+ if (p && *p) *dfree = strtoul(p, &p, 10);
+ while (p && *p & isspace(*p)) p++;
+ if (p && *p) *bsize = strtoul(p, NULL, 10);
+ else *bsize = 1024;
+ pclose (pp);
+ DEBUG (3, ("Parsed output of dfree, dsize=%d, dfree=%d, "
+ "bsize=%d\n", *dsize, *dfree, *bsize));
+
+ if (!*dsize) *dsize = 2048;
+ if (!*dfree) *dfree = 1024;
+ }
+ else
+ {
+ DEBUG (3, ("popen(dfree) failed: %s\n", sys_errlist[errno]));
+ }
+ }
+ else
+ fsusage(path, dfree, dsize);
if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) {
(*bsize) = bsize_q;
--- source/include/proto.h-orig Tue May 4 10:36:28 1999
+++ source/include/proto.h Fri Apr 30 15:15:17 1999
@@ -965,6 +965,7 @@
/*The following definitions come from param/loadparm.c */
+char *lp_dfree_command(void);
char *lp_logfile(void);
char *lp_smbrun(void);
char *lp_configfile(void);
More information about the samba-technical
mailing list