diff options
author | Michael Stone <michael@laptop.org> | 2009-12-06 01:08:39 (GMT) |
---|---|---|
committer | Michael Stone <michael@laptop.org> | 2009-12-06 01:19:50 (GMT) |
commit | 9b315631c53719706d8ff942f1a0660755efd5da (patch) | |
tree | 4fc337cd3fa2f2e290a5053dda0f3c849a2adab5 /rainbow | |
parent | b5f83361b157097b4990cb2043b44bb8aeb0be06 (diff) |
Add some logging to rainbow-gc.
Diffstat (limited to 'rainbow')
-rwxr-xr-x | rainbow/bin/rainbow-gc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/rainbow/bin/rainbow-gc b/rainbow/bin/rainbow-gc index 1dc7bf5..91869e9 100755 --- a/rainbow/bin/rainbow-gc +++ b/rainbow/bin/rainbow-gc @@ -20,7 +20,7 @@ def active_uid(uid): def sticky_uid(spool, uid): return exists(join(spool, "sticky_uids", uid)) -def gc_uid(spool, uid): +def gc_uid(log, spool, uid): """This function conservatively attempts to garbage-collect stale uid reservations. """ @@ -39,26 +39,34 @@ def gc_uid(spool, uid): assert uid_num >= 1000 and uid_num <= 65534 # XXX: magic numbers from util/spool.py if active_uid(uid) or sticky_uid(spool, uid): + log(1, "skipped uid %s", uid) return for table in ('uid_to_instance_dir', 'uid_to_home_dir', 'uid_to_gid', 'uid_to_xephyr_auth', 'uid_to_xephyr_cookie', 'uid_to_xephyr_display'): row = join(spool, table, uid) # NB: it is important that rm -rf doesn't follow links. <MS> - check_call(['/bin/rm', '-r', '-f', row]) + cmd = ['/bin/rm', '-r', '-f', row] + log(2, "%s", ' '.join(cmd)) + check_call(cmd) for row in glob(join(spool, 'gid_to_members', '*', uid)): # NB: it is important that rm -rf doesn't follow links. <MS> - check_call(['/bin/rm', '-r', '-f', row]) + cmd = ['/bin/rm', '-r', '-f', row] + log(2, "%s", ' '.join(cmd)) + check_call(cmd) # So long as we unlink the reservation last, we run no risk of seeing inconsistency unlink(reservation) + log(1, "cleaned uid %s", uid) def gc_spool(log, spool): ret = 0 uspool = join(spool, 'uid_pool') if exists(uspool) and isdir(uspool): for maybe_uid in listdir(uspool): - try: gc_uid(spool, maybe_uid) + try: gc_uid(log, spool, maybe_uid) + except KeyboardInterrupt: + raise except: trace() ret = 1 |