Gordon Messmer writes:
This version just returns -1 if there's no static limit on inodes, but it also disables the low block count checks.
Yes, I just realized that, so I've changed my mind. We definitely should check at least the number of available blocks.
How 'bout this one?
diff -ruw courier-0.44.2/courier/courierd.C courier-0.44.2-reiserfs/courier/courierd.C
--- courier-0.44.2/courier/courierd.C 2003-03-07 18:49:56.000000000 -0800
+++ courier-0.44.2-reiserfs/courier/courierd.C 2003-12-06 12:44:29.000000000 -0800
@@ -144,7 +144,7 @@
if (counter == 0)
{
- unsigned long nblock, ninodes;
+ unsigned long checkblocks, nblock, checkinodes, ninodes;
unsigned blocksize;
// Time to recheck disk free space. By default, remember
@@ -152,10 +152,10 @@
//
counter=100;
- if (freespace(MSGQDIR "/.", &nblock, &ninodes, &blocksize))
+ if (freespace(MSGQDIR "/.", &checkblocks, &nblock, &checkinodes,
&ninodes, &blocksize))
return (islow);
- if (ninodes < (unsigned long)(100+msgq::queue.GetSize()*2))
+ if (checkinodes && ninodes < (unsigned
long)(100+msgq::queue.GetSize()*2))
islow=1;
else
{
diff -ruw courier-0.44.2/courier/courier.h.in
courier-0.44.2-reiserfs/courier/courier.h.in
--- courier-0.44.2/courier/courier.h.in 2001-01-22 10:12:17.000000000 -0800
+++ courier-0.44.2-reiserfs/courier/courier.h.in 2003-12-06 12:37:46.000000000
-0800
@@ -133,7 +133,9 @@
char *dsnencodeorigaddr(const char *);
int freespace(const char *, /* Filename */
+ unsigned long *, /* # of blocks on fs */
unsigned long *, /* # of blocks free */
+ unsigned long *, /* # of inodes on fs */
unsigned long *, /* # of inodes free */
unsigned *); /* Block size */
diff -ruw courier-0.44.2/courier/libs/comstatfs.c
courier-0.44.2-reiserfs/courier/libs/comstatfs.c
--- courier-0.44.2/courier/libs/comstatfs.c 2000-05-15 23:18:31.000000000 -0700
+++ courier-0.44.2-reiserfs/courier/libs/comstatfs.c 2003-12-06 12:46:41.000000000
-0800
@@ -46,15 +46,19 @@
#ifdef DOIT
-int freespace(const char *ptr, unsigned long *nblocks,
- unsigned long *ninodes, unsigned *blksize)
+int freespace(const char *ptr,
+ unsigned long *tblocks, unsigned long *nblocks,
+ unsigned long *tinodes, unsigned long *ninodes,
+ unsigned *blksize)
{
#if HAVE_STATVFS
struct statvfs buf;
if (statvfs(ptr, &buf)) return (-1);
+#define BTOTAL buf.f_blocks
#define BAVAIL buf.f_bavail
+#define ITOTAL buf.f_files
#define IAVAIL buf.f_favail
*blksize=buf.f_bsize;
@@ -65,17 +69,23 @@
if (statfs(ptr, &buf)) return (-1);
+#define BTOTAL buf.f_blocks
#define BAVAIL buf.f_bfree
+#define ITOTAL buf.f_files
#define IAVAIL buf.f_ffree
*blksize=buf.f_bsize;
#endif
#endif
+ *tblocks= BTOTAL;
*nblocks= BAVAIL;
+ *tinodes= ITOTAL;
*ninodes= IAVAIL;
+ if (*tblocks != BTOTAL) *tblocks= ~0; /* Overflow */
if (*nblocks != BAVAIL) *nblocks= ~0; /* Overflow */
+ if (*tinodes != ITOTAL) *tinodes= ~0; /* Overflow */
if (*ninodes != IAVAIL) *ninodes= ~0; /* Overflow */
return (0);
diff -ruw courier-0.44.2/courier/submit.C courier-0.44.2-reiserfs/courier/submit.C
--- courier-0.44.2/courier/submit.C 2003-10-04 21:47:50.000000000 -0700
+++ courier-0.44.2-reiserfs/courier/submit.C 2003-12-06 12:43:38.000000000 -0800
@@ -152,7 +152,7 @@
{
static unsigned nsubmitters;
static unsigned min_inodes=0;
-unsigned long nfreeblocks, nfreeinodes;
+unsigned long checkblocks, nfreeblocks, checkinodes, nfreeinodes;
unsigned blksize;
unsigned dummy;
@@ -172,12 +172,12 @@
*availbytes=65536;
- if (freespace( ".", &nfreeblocks, &nfreeinodes, &blksize))
+ if (freespace( ".", &checkblocks, &nfreeblocks, &checkinodes, &nfreeinodes,
&blksize))
{
return (0);
}
- if (nfreeinodes < min_inodes) return (-1);
+ if (checkinodes && nfreeinodes < min_inodes) return (-1);
if (nfreeblocks < blksize * nsubmitters/65536 + 100)
*availbytes=4096;
