Bug 122811 - [periodic] [patch] the daily_clean_disks scripts walks file systems it shouldn't
Summary: [periodic] [patch] the daily_clean_disks scripts walks file systems it shouldn't
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 7.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Brian Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-16 04:10 UTC by mwm
Modified: 2009-06-23 11:00 UTC (History)
0 users

See Also:


Attachments
file.diff (1.25 KB, patch)
2008-04-16 04:10 UTC, mwm
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mwm 2008-04-16 04:10:01 UTC
	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.

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
How-To-Repeat: 	Run the clean-disks periodic on a system with non-local file 
	systems mounted, and watch it walk them.
Comment 1 Gavin Atkinson freebsd_committer freebsd_triage 2009-04-23 12:21:54 UTC
Also see conf/133070 for a different approach to solving the same issue.
I'm not sure which approach is best.
Comment 2 Brian Somers freebsd_committer freebsd_triage 2009-05-30 09:36:00 UTC
Responsible Changed
From-To: freebsd-bugs->brian

I'll fix this (and also pr 133070 which I've closed as a dup of 
this)
Comment 3 Brian Somers freebsd_committer freebsd_triage 2009-06-02 08:36:03 UTC
State Changed
From-To: open->patched

Fixed with r193302 - I'll MFC in 3 weeks.
Comment 4 dfilter service freebsd_committer freebsd_triage 2009-06-02 08:36:06 UTC
Author: brian
Date: Tue Jun  2 07:35:51 2009
New Revision: 193302
URL: http://svn.freebsd.org/changeset/base/193302

Log:
  Rather than using both -prune (which requires directory-first tree traversal)
  and -delete (which implies depth-first traversal), avoid using -delete in
  favour of -execdir.
  
  This has a side-effect of not removing directories that contain files,
  even if we delete all of those files, but IMHO that's a better option
  than specifying all possible local filesystem types in this script.
  
  PR:		122811
  MFC after:	3 weeks

Modified:
  head/etc/periodic/daily/100.clean-disks

Modified: head/etc/periodic/daily/100.clean-disks
==============================================================================
--- head/etc/periodic/daily/100.clean-disks	Tue Jun  2 06:55:32 2009	(r193301)
+++ head/etc/periodic/daily/100.clean-disks	Tue Jun  2 07:35:51 2009	(r193302)
@@ -29,7 +29,7 @@ case "$daily_clean_disks_enable" in
 	    echo ""
 	    echo "Cleaning disks:"
 	    set -f noglob
-	    args="$args -name "`echo "$daily_clean_disks_files" |
+	    args="-name "`echo "$daily_clean_disks_files" |
 		sed -e 's/^[ 	]*//' \
 		    -e 's/[ 	]*$//' \
 		    -e 's/[ 	][ 	]*/ -o -name /g'`
@@ -41,9 +41,9 @@ case "$daily_clean_disks_enable" in
 		    print=;;
 	    esac
 
-	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
-		\( $args \) -atime +$daily_clean_disks_days -delete $print |
-		tee /dev/stderr | wc -l)
+	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -prune -o \
+		\( $args \) -atime +$daily_clean_disks_days \
+		-execdir rm -df {} \; $print | tee /dev/stderr | wc -l)
 	    [ -z "$print" ] && rc=0
 	    [ $rc -gt 1 ] && rc=1
 	    set -f glob
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 5 Brian Somers freebsd_committer freebsd_triage 2009-06-23 10:52:22 UTC
State Changed
From-To: patched->closed

Merged to stable/7 - r194690
Comment 6 dfilter service freebsd_committer freebsd_triage 2009-06-23 10:52:47 UTC
Author: brian
Date: Tue Jun 23 09:51:38 2009
New Revision: 194690
URL: http://svn.freebsd.org/changeset/base/194690

Log:
  MFC: r193302: Avoid using find -delete in favour of find -prune
  
  PR:		122811

Modified:
  stable/7/etc/   (props changed)
  stable/7/etc/periodic/daily/100.clean-disks

Modified: stable/7/etc/periodic/daily/100.clean-disks
==============================================================================
--- stable/7/etc/periodic/daily/100.clean-disks	Tue Jun 23 09:50:50 2009	(r194689)
+++ stable/7/etc/periodic/daily/100.clean-disks	Tue Jun 23 09:51:38 2009	(r194690)
@@ -29,7 +29,7 @@ case "$daily_clean_disks_enable" in
 	    echo ""
 	    echo "Cleaning disks:"
 	    set -f noglob
-	    args="$args -name "`echo "$daily_clean_disks_files" |
+	    args="-name "`echo "$daily_clean_disks_files" |
 		sed -e 's/^[ 	]*//' \
 		    -e 's/[ 	]*$//' \
 		    -e 's/[ 	][ 	]*/ -o -name /g'`
@@ -41,9 +41,9 @@ case "$daily_clean_disks_enable" in
 		    print=;;
 	    esac
 
-	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
-		\( $args \) -atime +$daily_clean_disks_days -delete $print |
-		tee /dev/stderr | wc -l)
+	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -prune -o \
+		\( $args \) -atime +$daily_clean_disks_days \
+		-execdir rm -df {} \; $print | tee /dev/stderr | wc -l)
 	    [ -z "$print" ] && rc=0
 	    [ $rc -gt 1 ] && rc=1
 	    set -f glob
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"