Page MenuHomeFreeBSD

D2587.diff
No OneTemporary

D2587.diff

Index: sbin/savecore/savecore.8
===================================================================
--- sbin/savecore/savecore.8
+++ sbin/savecore/savecore.8
@@ -125,18 +125,6 @@
.Nm
successfully runs.
.Pp
-The
-.Nm
-utility
-also checks the available disk space before attempting to make the copies.
-If there is insufficient disk space in the file system containing
-.Ar directory ,
-or if the file
-.Ar directory Ns Pa /minfree
-exists and the number of free kilobytes (for non-superusers) in the
-file system after the copies were made would be less than the number
-in the first line of this file, the copies are not attempted.
-.Pp
If
.Nm
successfully copies the kernel and the core dump, the core dump is cleared
@@ -166,5 +154,3 @@
.Pp
Support for kernel textdumps appeared in
.Fx 7.1 .
-.Sh BUGS
-The minfree code does not consider the effect of compression or sparse files.
Index: sbin/savecore/savecore.c
===================================================================
--- sbin/savecore/savecore.c
+++ sbin/savecore/savecore.c
@@ -183,39 +183,6 @@
fclose(fp);
}
-static off_t
-file_size(const char *path)
-{
- struct stat sb;
-
- /* Ignore all errors, those file may not exists. */
- if (stat(path, &sb) == -1)
- return (0);
- return (sb.st_size);
-}
-
-static off_t
-saved_dump_size(int bounds)
-{
- static char path[PATH_MAX];
- off_t dumpsize;
-
- dumpsize = 0;
-
- (void)snprintf(path, sizeof(path), "info.%d", bounds);
- dumpsize += file_size(path);
- (void)snprintf(path, sizeof(path), "vmcore.%d", bounds);
- dumpsize += file_size(path);
- (void)snprintf(path, sizeof(path), "vmcore.%d.gz", bounds);
- dumpsize += file_size(path);
- (void)snprintf(path, sizeof(path), "textdump.tar.%d", bounds);
- dumpsize += file_size(path);
- (void)snprintf(path, sizeof(path), "textdump.tar.%d.gz", bounds);
- dumpsize += file_size(path);
-
- return (dumpsize);
-}
-
static void
saved_dump_remove(int bounds)
{
@@ -244,49 +211,6 @@
(void)unlink("textdump.tar.last.gz");
}
-/*
- * Check that sufficient space is available on the disk that holds the
- * save directory.
- */
-static int
-check_space(const char *savedir, off_t dumpsize, int bounds)
-{
- FILE *fp;
- off_t minfree, spacefree, totfree, needed;
- struct statfs fsbuf;
- char buf[100];
-
- if (statfs(".", &fsbuf) < 0) {
- syslog(LOG_ERR, "%s: %m", savedir);
- exit(1);
- }
- spacefree = ((off_t) fsbuf.f_bavail * fsbuf.f_bsize) / 1024;
- totfree = ((off_t) fsbuf.f_bfree * fsbuf.f_bsize) / 1024;
-
- if ((fp = fopen("minfree", "r")) == NULL)
- minfree = 0;
- else {
- if (fgets(buf, sizeof(buf), fp) == NULL)
- minfree = 0;
- else
- minfree = atoi(buf);
- (void)fclose(fp);
- }
-
- needed = dumpsize / 1024 + 2; /* 2 for info file */
- needed -= saved_dump_size(bounds);
- if ((minfree > 0 ? spacefree : totfree) - needed < minfree) {
- syslog(LOG_WARNING,
- "no dump, not enough free space on device (%lld available, need %lld)",
- (long long)(minfree > 0 ? spacefree : totfree),
- (long long)needed);
- return (0);
- }
- if (spacefree - needed < 0)
- syslog(LOG_WARNING,
- "dump performed, but free space threshold crossed");
- return (1);
-}
#define BLOCKSIZE (1<<12)
#define BLOCKMASK (~(BLOCKSIZE-1))
@@ -613,11 +537,6 @@
if (verbose)
printf("Checking for available free space\n");
- if (!check_space(savedir, dumpsize, bounds)) {
- nerr++;
- goto closefd;
- }
-
writebounds(bounds + 1);
saved_dump_remove(bounds);

File Metadata

Mime Type
text/plain
Expires
Thu, Feb 27, 10:07 AM (19 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16866668
Default Alt Text
D2587.diff (3 KB)

Event Timeline