bin/122811: the daily_clean_disks scripts walks file systems it
shouldn't
Mike Meyer
mwm at mired.org
Wed Apr 16 03:10:01 UTC 2008
>Number: 122811
>Category: bin
>Synopsis: the daily_clean_disks scripts walks file systems it shouldn't
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Apr 16 03:10:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Mike Meyer
>Release: FreeBSD 7.0-STABLE amd64
>Organization:
Meyer Consulting
>Environment:
System: FreeBSD bhuda.mired.org 7.0-STABLE FreeBSD 7.0-STABLE #0: Tue Apr 8 01:24:21 EDT 2008 mwm at bhuda.mired.org:/usr/src/sys/amd64/compile/BHUDA amd64
>Description:
The daily clean disks script tries to use the find -prune and -delete
flags to together, which is documented (though obscurely) as not working:
-delete is documented as implying depth-first traversal, as with -d, and
-prune is documented as having no effect if the -d option was specified.
This means that, while the perioud daily-clean-disks script
tries to limit itself to locally mounted file systems and
read-write file systems, it will actually fails to do so.
>How-To-Repeat:
Run the clean-disks periodic on a system with non-local file
systems mounted, and watch it walk them.
>Fix:
The attached patch changes adds a new knob -
daily_clean_disks_fs_types, and individually walks file
systems of those types if they aren't read-only.
Only in /usr/src/etc/defaults: Makefile
diff -ru /usr/src/etc/defaults/periodic.conf defaults/periodic.conf
--- /usr/src/etc/defaults/periodic.conf 2008-01-27 03:07:14.000000000 -0500
+++ defaults/periodic.conf 2008-04-15 22:27:22.758031816 -0400
@@ -40,6 +40,7 @@
daily_clean_disks_files="[#,]* .#* a.out *.core *.CKP .emacs_[0-9]*"
daily_clean_disks_days=3 # If older than this
daily_clean_disks_verbose="YES" # Mention files deleted
+daily_clean_disks_fs_types="ufs,zfs" # File system types to clean
# 110.clean-tmps
daily_clean_tmps_enable="NO" # Delete stuff daily
diff -ru /usr/src/etc/periodic/daily/100.clean-disks periodic/daily/100.clean-disks
--- /usr/src/etc/periodic/daily/100.clean-disks 2001-04-25 08:11:54.000000000 -0400
+++ periodic/daily/100.clean-disks 2008-04-03 16:15:55.000000000 -0400
@@ -41,7 +41,10 @@
print=;;
esac
- rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
+ disks=$(mount -t $daily_clean_disks_fs_types \
+ | sed -e 's/.* on //' -e 's/ *(.*//' -e '/read-only/d')
+ echo $disks
+ rc=$(find -x $disks \
\( $args \) -atime +$daily_clean_disks_days -delete $print |
tee /dev/stderr | wc -l)
[ -z "$print" ] && rc=0
Only in /usr/src/etc/periodic/daily: Makefile
Only in /usr/src/etc/periodic/daily: type
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list