[1806] in athena10

home help back first fref pref prev next nref lref last post

Fwd: Athena delete

daemon@ATHENA.MIT.EDU (Anders Kaseorg)
Sun Mar 22 02:06:55 2009

From: Anders Kaseorg <andersk@MIT.EDU>
To: debathena@mit.edu
Content-Type: multipart/mixed; boundary="=-EIv/icJd/ycjX1bT3XWI"
Date: Sun, 22 Mar 2009 02:06:01 -0400
Message-Id: <1237701961.23178.9.camel@balanced-tree>
Mime-Version: 1.0


--=-EIv/icJd/ycjX1bT3XWI
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit

These four messages came from a thread on sipb@ today.  The last message
dropped sipb@ from the Cc, and includes some patches to delete.

I’m not sure who jik is, and I don’t really like the tone of his request
that we add an RPM specfile to our source tree (plus I’m already not so
happy that we added debian directories there; software _should_ be
separable from its packaging), but his patches might be worth looking
at.

Anders


--=-EIv/icJd/ycjX1bT3XWI
Content-Disposition: inline
Content-Type: message/rfc822

Return-Path: <belg4mit@alum.mit.edu>
Received: from po10.mit.edu ([unix socket]) by po10.mit.edu (Cyrus v2.1.5)
 with LMTP; Sat, 21 Mar 2009 16:11:18 -0400
X-Sieve: CMU Sieve 2.2
Received: from fort-point-station.mit.edu by po10.mit.edu (8.13.6/4.7) id
 n2LKBG5Y003066; Sat, 21 Mar 2009 16:11:16 -0400 (EDT)
Received: from mit.edu (W92-130-BARRACUDA-2.MIT.EDU [18.7.21.223]) by
 fort-point-station.mit.edu (8.13.6/8.9.2) with ESMTP id n2LKATT5006287 for
 <sipb@mit.edu>; Sat, 21 Mar 2009 16:10:29 -0400 (EDT)
Received: from db.pthbb.org (localhost [127.0.0.1]) by mit.edu (Spam
 Firewall) with ESMTP id 1725D13B032F for <sipb@mit.edu>; Sat, 21 Mar 2009
 16:10:27 -0400 (EDT)
Received: from db.pthbb.org (67.228.133.36-static.reverse.softlayer.com
 [67.228.133.36]) by mit.edu with ESMTP id woz2T049k1ZuthAw for
 <sipb@mit.edu>; Sat, 21 Mar 2009 16:10:27 -0400 (EDT)
Received-SPF: softfail (mit.edu: domain of transitioning
 belg4mit@alum.mit.edu does not designate 67.228.133.36 as permitted sender)
 receiver=mit.edu; client_ip=67.228.133.36;
 envelope-from=belg4mit@alum.mit.edu;
Received: by db.pthbb.org (Postfix, from userid 502) id A5A33E4D8CD4; Sat,
 21 Mar 2009 13:10:27 -0700 (PDT)
Received: from pthbb.org (localhost [127.0.0.1]) by db.pthbb.org (Postfix)
 with ESMTP id A2C1DE4D8CD3; Sat, 21 Mar 2009 13:10:27 -0700 (PDT)
Subject: Athena delete
To: sipb@mit.edu
cc: jik@cam.ov.com, jik@alum.mit.edu
From: belg4mit@alum.mit.edu
Reply-To: belg4mit@pthbb.org
Return-Receipt-To: belg4mit@pthbb.org
X-Organization: a) Discordia b) none c) what's that?
X-Content-Typo: gibberish, charset=ascii-art
X-Keywords: 
Date: Sat, 21 Mar 2009 13:10:27 -0700
Message-Id: <20090321201027.A5A33E4D8CD4@db.pthbb.org>
X-Spam-Score: 5.14
X-Spam-Level: ***** (5.14)
X-Spam-Flag: NO
X-Scanned-By: MIMEDefang 2.42
X-Evolution-Source: imap://andersk@andersk.mail.mit.edu/
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit

Hello,

SIPB seems to host a copy of Athena's delete for public use:
  ftp://pit-manager.mit.edu/pub/delete/
  (linked from http://freshmeat.net/projects/athena-delete
   & mentioned on stale http://stuff.mit.edu/~jik/software/delete.html)

I'm glad, and have used it on many personal machines over the users after
having become accustomed to it on Athena. Alas it's rather stale, and no
seems broken on modern linuxes. Although most functionality is present,
recursion e.g; purge; seg faults. Surely this must have been remedied for
Athena, which is now predominantly Linux. Would it be possible to provide
an updated release?

Sincerely,

Jerrad Pierce
-- 
Free map of local environmental resources: http://CambridgeMA.GreenMap.org
--
MOTD on Setting Orange, the 7th of Discord, in the YOLD 3175:
I cuss, You cuss, We all cuss for asparagus

--=-EIv/icJd/ycjX1bT3XWI
Content-Disposition: inline
Content-Type: message/rfc822

Return-Path: <andersk@MIT.EDU>
Received: from po10.mit.edu ([unix socket]) by po10.mit.edu (Cyrus v2.1.5)
 with LMTP; Sat, 21 Mar 2009 17:09:49 -0400
X-Sieve: CMU Sieve 2.2
Received: from biscayne-one-station.mit.edu by po10.mit.edu (8.13.6/4.7) id
 n2LL9l0l028949; Sat, 21 Mar 2009 17:09:47 -0400 (EDT)
Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by
 biscayne-one-station.mit.edu (8.13.6/8.9.2) with ESMTP id n2LL9iWe012128;
 Sat, 21 Mar 2009 17:09:44 -0400 (EDT)
Received: from localhost (VINEGAR-POT.MIT.EDU [18.181.0.51]) (authenticated
 bits=0) (User authenticated as andersk@ATHENA.MIT.EDU) by outgoing.mit.edu
 (8.13.6/8.12.4) with ESMTP id n2LL9hng024711; Sat, 21 Mar 2009 17:09:43
 -0400 (EDT)
Date: Sat, 21 Mar 2009 17:09:43 -0400 (EDT)
From: Anders Kaseorg <andersk@MIT.EDU>
To: belg4mit@pthbb.org
cc: sipb@mit.edu, jik@cam.ov.com, jik@alum.mit.edu
Subject: Re: Athena delete
In-Reply-To: <20090321201027.A5A33E4D8CD4@db.pthbb.org>
Message-ID: <alpine.DEB.2.00.0903211702260.4457@vinegar-pot.mit.edu>
References: <20090321201027.A5A33E4D8CD4@db.pthbb.org>
User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Scanned-By: MIMEDefang 2.42
X-Spam-Flag: NO
X-Spam-Score: -5
X-Evolution-Source: imap://andersk@andersk.mail.mit.edu/
Content-Transfer-Encoding: 7bit

On Sat, 21 Mar 2009, belg4mit@alum.mit.edu wrote:
> SIPB seems to host a copy of Athena's delete for public use:
>   ftp://pit-manager.mit.edu/pub/delete/
>   (linked from http://freshmeat.net/projects/athena-delete
>    & mentioned on stale http://stuff.mit.edu/~jik/software/delete.html)
> 
> I'm glad, and have used it on many personal machines over the users after
> having become accustomed to it on Athena. Alas it's rather stale, and no
> seems broken on modern linuxes. Although most functionality is present,
> recursion e.g; purge; seg faults. Surely this must have been remedied for
> Athena, which is now predominantly Linux. Would it be possible to provide
> an updated release?

Sure.  delete is currently maintained in the Debathena svn repository:
  svn co svn://debathena.mit.edu/athena/trunk/athena/bin/delete

You can get a source tarball and Debian/Ubuntu packages from our APT 
repository.
  <http://debathena.mit.edu/advanced-installation>
  <http://debathena.mit.edu/apt/pool/debathena/d/debathena-delete/>

Anders
SIPB Debathena team <http://debathena.mit.edu/>

--=-EIv/icJd/ycjX1bT3XWI
Content-Disposition: inline
Content-Type: message/rfc822

Return-Path: <belg4mit@pthbb.org>
Received: from po10.mit.edu ([unix socket]) by po10.mit.edu (Cyrus v2.1.5)
 with LMTP; Sat, 21 Mar 2009 17:30:22 -0400
X-Sieve: CMU Sieve 2.2
Received: from fort-point-station.mit.edu by po10.mit.edu (8.13.6/4.7) id
 n2LLULMh007328; Sat, 21 Mar 2009 17:30:22 -0400 (EDT)
Received: from mit.edu (W92-130-BARRACUDA-1.MIT.EDU [18.7.21.220]) by
 fort-point-station.mit.edu (8.13.6/8.9.2) with ESMTP id n2LLUBDO012821 for
 <andersk@MIT.EDU>; Sat, 21 Mar 2009 17:30:11 -0400 (EDT)
Received: from db.pthbb.org (localhost [127.0.0.1]) by mit.edu (Spam
 Firewall) with ESMTP id 5342D153BD36; Sat, 21 Mar 2009 17:30:11 -0400 (EDT)
Received: from db.pthbb.org (67.228.133.36-static.reverse.softlayer.com
 [67.228.133.36]) by mit.edu with ESMTP id JdAdllr7sDALEYIG; Sat, 21 Mar
 2009 17:30:10 -0400 (EDT)
Received-SPF: pass (mit.edu: domain of belg4mit@pthbb.org designates
 67.228.133.36 as permitted sender) receiver=mit.edu;
 client_ip=67.228.133.36; envelope-from=belg4mit@pthbb.org;
Received: by db.pthbb.org (Postfix, from userid 502) id 96902E4D8CD7; Sat,
 21 Mar 2009 14:30:10 -0700 (PDT)
Received: from pthbb.org (localhost [127.0.0.1]) by db.pthbb.org (Postfix)
 with ESMTP id 93DB4E4D8CD6; Sat, 21 Mar 2009 14:30:10 -0700 (PDT)
To: Anders Kaseorg <andersk@MIT.EDU>
cc: sipb@MIT.EDU, jik@cam.ov.com, jik@alum.mit.edu
Subject: Re: Athena delete
In-reply-to: <alpine.DEB.2.00.0903211702260.4457@vinegar-pot.mit.edu>
References: <20090321201027.A5A33E4D8CD4@db.pthbb.org>
	 <alpine.DEB.2.00.0903211702260.4457@vinegar-pot.mit.edu>
Comments: In-reply-to Anders Kaseorg <andersk@MIT.EDU> message dated "Sat,
 21 Mar 2009 17:09:43 -0400."
Date: Sat, 21 Mar 2009 14:30:10 -0700
From: belg4mit@pthbb.org
Message-Id: <20090321213010.96902E4D8CD7@db.pthbb.org>
X-Spam-Score: 0.55
X-Spam-Flag: NO
X-Scanned-By: MIMEDefang 2.42
X-Evolution-Source: imap://andersk@andersk.mail.mit.edu/
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit

Works wonderfully, thank you.

I assume Freshmeat, FTP, and maybe jik's page will (eventually) be updated?

Thanks again,

-Jerrad
-- 
Free map of local environmental resources: http://CambridgeMA.GreenMap.org
--
MOTD on Setting Orange, the 7th of Discord, in the YOLD 3175:
I cuss, You cuss, We all cuss for asparagus

--=-EIv/icJd/ycjX1bT3XWI
Content-Disposition: inline
Content-Type: message/rfc822

Return-Path: <jik@kamens.brookline.ma.us>
Received: from po10.mit.edu ([unix socket]) by po10.mit.edu (Cyrus v2.1.5)
 with LMTP; Sun, 22 Mar 2009 01:34:57 -0400
X-Sieve: CMU Sieve 2.2
Received: from fort-point-station.mit.edu by po10.mit.edu (8.13.6/4.7) id
 n2M5Yutq006931; Sun, 22 Mar 2009 01:34:57 -0400 (EDT)
Received: from mit.edu (W92-130-BARRACUDA-2.MIT.EDU [18.7.21.223]) by
 fort-point-station.mit.edu (8.13.6/8.9.2) with ESMTP id n2M5YlBk024585 for
 <andersk@MIT.EDU>; Sun, 22 Mar 2009 01:34:47 -0400 (EDT)
Received: from jik3.kamens.brookline.ma.us (localhost [127.0.0.1]) by
 mit.edu (Spam Firewall) with ESMTP id 1768313B5E34 for <andersk@MIT.EDU>;
 Sun, 22 Mar 2009 01:34:40 -0400 (EDT)
Received: from jik3.kamens.brookline.ma.us (jik3.kamens.brookline.ma.us
 [128.177.28.63]) by mit.edu with ESMTP id 19hDPLiVXuYmOR9z (version=TLSv1
 cipher=AES256-SHA bits=256 verify=NO) for <andersk@MIT.EDU>; Sun, 22 Mar
 2009 01:34:40 -0400 (EDT)
Received: from jik2.kamens.brookline.ma.us (jik2-openvpn [10.100.65.34]) by
 jik3.kamens.brookline.ma.us (8.13.8/8.13.8) with ESMTP id n2M5YdDQ024803;
 Sun, 22 Mar 2009 01:34:40 -0400
Received: from jik2.kamens.brookline.ma.us (jik2.kamens.brookline.ma.us
 [10.100.65.34]) by jik2.kamens.brookline.ma.us (8.14.3/8.14.3) with ESMTP
 id n2M5YYWt026694; Sun, 22 Mar 2009 01:34:34 -0400
Message-ID: <49C5CDEA.6000707@kamens.brookline.ma.us>
Date: Sun, 22 Mar 2009 01:34:34 -0400
From: Jonathan Kamens <jik@kamens.brookline.ma.us>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.19)
 Gecko/20090105 Fedora/2.0.0.19-1.fc10 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666
MIME-Version: 1.0
To: belg4mit@pthbb.org
CC: Anders Kaseorg <andersk@MIT.EDU>
Subject: Re: Athena delete
References: <20090321201027.A5A33E4D8CD4@db.pthbb.org>
	 <alpine.DEB.2.00.0903211702260.4457@vinegar-pot.mit.edu>
	 <20090321213010.96902E4D8CD7@db.pthbb.org>
In-Reply-To: <20090321213010.96902E4D8CD7@db.pthbb.org>
Content-Type: multipart/mixed; boundary="------------040503020203070208090505"
X-Spam-Score: 0.00
X-Spam-Flag: NO
X-Scanned-By: MIMEDefang 2.42
X-Evolution-Source: imap://andersk@andersk.mail.mit.edu/


--------------040503020203070208090505
Content-Type: multipart/alternative; boundary="------------020400000001020501040102"


--------------020400000001020501040102
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Wow, a publicly accessible source tree.  What a novelty!

I suppose this is an opportunity to get my personal changes to delete 
(which I still use, of course :-) folded back into the Debathena source 
tree so that (a) I no longer need to maintain a separate copy of the 
sources and (b) other people can benefit from the fixes I've made.

But I'd prefer to do that only do that you're willing to stick into the 
tree the files necessary to build an RPM (although the Debian build 
won't use them, obviously), since I still use an RPM-based system.

See the attached diff against the Subversion URL you sent, which makes 
the following changes (bold items are new functionality and/or 
significant bug fixes):

    * *(delete.c) When recursively deleting a directory, read in the
      directory's entire contents before deleting anything.  Otherwise,
      readdir could get confused and not return all of the files in the
      directory.*
    * (lsdel.c,undelete.c, expunge.c, delete_errs.et) Change the
      ENOMATCH error constant to DELETE_ENOMATCH to avoid conflicting
      with a system error constant of the same name on some platforms.
    * *(lsdel.c, expunge.c, directories.c, directories.h) When printing
      an amount of space, print it in friendly units, e.g., KB, MB or
      GB, rather than always printing kb.*
    * *(lsdel.c) Fix a bug where the same memory was being freed twice.*
    * (stack.c) Fix compiler nit by including <string.h>
    * (delete.spec, rpm/Makefile.am, rpm/configure.ac) Add files for
      building an RPM.
    * (directories.c, util.c, directories.h) Change the "st_chtime"
      structure member to "st_ctim" to avoid a header file conflict on
      some platforms.
    * (pattern.c, pattern.h) When adding to an array, leave some extra
      space at the end so that we don't have to keep growing it every time.
    * (pattern.c) Don't try to use symbolic links on platforms that
      don't have them (slight performance optimization).
    * (directories.h) Add a missing function declaration to fix a
      compiler nit.

I've been running with all of these code changes for a long time, and 
they all work, but of course I may have messed something up when doing 
the merge into your source tree, so a code review by someone else would 
probably be a good idea before you check these changes in.

Or you could just give me a Subversion account and write access to this 
directory and I'll check them in myself :-).

   jik

On 03/21/2009 05:30 PM, belg4mit@pthbb.org wrote:
> Works wonderfully, thank you.
>
> I assume Freshmeat, FTP, and maybe jik's page will (eventually) be updated?
>
> Thanks again,
>
> -Jerrad
>    

--------------020400000001020501040102
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Wow, a publicly accessible source tree.&nbsp; What a novelty!<br>
<br>
I suppose this is an opportunity to get my personal changes to delete
(which I still use, of course :-) folded back into the Debathena source
tree so that (a) I no longer need to maintain a separate copy of the
sources and (b) other people can benefit from the fixes I've made.<br>
<br>
But I'd prefer to do that only do that you're willing to stick into the
tree the files necessary to build an RPM (although the Debian build
won't use them, obviously), since I still use an RPM-based system.<br>
<br>
See the attached diff against the Subversion URL you sent, which makes
the following changes (bold items are new functionality and/or
significant bug fixes):<br>
<ul>
  <li><b>(delete.c) When recursively deleting a directory, read in the
directory's entire contents before deleting anything.&nbsp; Otherwise,
readdir could get confused and not return all of the files in the
directory.</b></li>
  <li>(lsdel.c,undelete.c, expunge.c, delete_errs.et) Change the
ENOMATCH error constant to DELETE_ENOMATCH to avoid conflicting with a
system error constant of the same name on some platforms.</li>
  <li><b>(lsdel.c, expunge.c, directories.c, directories.h) When
printing an amount of space, print it in friendly units, e.g., KB, MB
or GB, rather than always printing kb.</b></li>
  <li><b>(lsdel.c) Fix a bug where the same memory was being freed
twice.</b></li>
  <li>(stack.c) Fix compiler nit by including &lt;string.h&gt;</li>
  <li>(delete.spec, rpm/Makefile.am, rpm/configure.ac) Add files for
building an RPM.</li>
  <li>(directories.c, util.c, directories.h) Change the "st_chtime"
structure member to "st_ctim" to avoid a header file conflict on some
platforms.</li>
  <li>(pattern.c, pattern.h) When adding to an array, leave some extra
space at the end so that we don't have to keep growing it every time.</li>
  <li>(pattern.c) Don't try to use symbolic links on platforms that
don't have them (slight performance optimization).</li>
  <li>(directories.h) Add a missing function declaration to fix a
compiler nit.</li>
</ul>
I've been running with all of these code changes for a long time, and
they all work, but of course I may have messed something up when doing
the merge into your source tree, so a code review by someone else would
probably be a good idea before you check these changes in.<br>
<br>
Or you could just give me a Subversion account and write access to this
directory and I'll check them in myself :-).<br>
<br>
&nbsp; jik<br>
<br>
On 03/21/2009 05:30 PM, <a class="moz-txt-link-abbreviated" href="mailto:belg4mit@pthbb.org">belg4mit@pthbb.org</a> wrote:
<blockquote cite="mid:20090321213010.96902E4D8CD7@db.pthbb.org"
 type="cite">
  <pre wrap="">Works wonderfully, thank you.

I assume Freshmeat, FTP, and maybe jik's page will (eventually) be updated?

Thanks again,

-Jerrad
  </pre>
</blockquote>
</body>
</html>

--------------020400000001020501040102--

--------------040503020203070208090505
Content-Type: text/plain; name="debathena-delete-jik.patch"
Content-Disposition: attachment; filename="debathena-delete-jik.patch"
Content-Transfer-Encoding: 7bit

Index: delete.c
===================================================================
--- delete.c	(revision 23641)
+++ delete.c	(working copy)
@@ -357,7 +357,9 @@
      int status = 0;
      char newfile[MAXPATHLEN];
      int retval = 0;
-     
+     char **dir_contents = 0;
+     int num_dir_contents = 0, dir_contents_size = 0;
+
      if (interactive && recursed) {
 	  printf("%s: remove directory %s? ", whoami, filename);
 	  if (! yes()) {
@@ -378,20 +380,33 @@
 	       continue;
 	  if (is_deleted(dp->d_name))
 	       continue;
-	  else {
-	       (void) strcpy(newfile, append(filename, dp->d_name));
-	       if (! *newfile) {
-		    error(filename);
-		    status = error_code;
-	       }
-
-	       retval = delete(newfile, 1);
-	       if (retval) {
-		    error(newfile);
-		    status = retval;
-	       }
+	  (void) strcpy(newfile, append(filename, dp->d_name));
+	  if (! *newfile) {
+	    error(filename);
+	    status = error_code;
+	    break;
 	  }
+	  if ((retval = add_str(&dir_contents, num_dir_contents,
+				&dir_contents_size, newfile))) {
+	    error(filename);
+	    status = retval;
+	    break;
+	  }
+	  num_dir_contents++;
      }
+
+     if (!status && num_dir_contents) {
+       int i;
+       for (i = 0; i < num_dir_contents; i++) {
+	 retval = delete(dir_contents[i], 1);
+	 if (retval) {
+	   error(dir_contents[i]);
+	   status = retval;
+	 }
+       }
+     }
+
+     free_list(dir_contents, num_dir_contents);
      closedir(dirp);
 
      if (status && (! emulate_rm)) {
Index: lsdel.c
===================================================================
--- lsdel.c	(revision 23641)
+++ lsdel.c	(working copy)
@@ -192,7 +192,7 @@
 		    }
 	       }
 	       else {
-		    set_error(ENOMATCH);
+		    set_error(DELETE_ENOMATCH);
 		    error(args[num - 1]);
 		    status = error_code;
 		    continue;
@@ -205,10 +205,12 @@
 	       return error_code;
 	  }
      }
-     if (yield)
-	  printf("\nTotal space taken up by file%s: %dk\n",
-		 (total == 1 ? "" : "s"), space_to_k(space_total));
-
+     if (yield) {
+       char *friendly = space_to_friendly(space_total);
+       printf("\nTotal space taken up by file%s: %s\n",
+	      (total == 1 ? "" : "s"), friendly);
+       free(friendly);
+     }
      return status;
 }
 
@@ -337,7 +339,6 @@
      for (last = 0, i = 1; i < *number; i++) {
 	  if (! strcmp(files[last], files[i])) {
 	       free (files[i]);
-	       free (files[i]);
 	       files[i] = (char *) NULL;
 	  }
 	  else
Index: stack.c
===================================================================
--- stack.c	(revision 23641)
+++ stack.c	(working copy)
@@ -13,6 +13,7 @@
      static char rcsid_stack_c[] = "$Id: stack.c,v 1.13 1999-01-22 23:09:06 ghudson Exp $";
 #endif
 
+#include <string.h>
 #include <sys/types.h>
 #include <stdio.h>
 #include <errno.h>
Index: undelete.c
===================================================================
--- undelete.c	(revision 23641)
+++ undelete.c	(working copy)
@@ -188,7 +188,7 @@
 	       set_error(ENOENT)
 	  }
 	  else
-	       set_error(ENOMATCH);
+	       set_error(DELETE_ENOMATCH);
 	  error(name);
 	  return error_code;
      }
Index: delete.spec
===================================================================
--- delete.spec	(revision 0)
+++ delete.spec	(revision 0)
@@ -0,0 +1,48 @@
+Summary: Recoverable file removal by renaming rather than deleting
+Name: debathena-delete
+Version: 10.0.0
+Release: 1
+License: MIT
+Group: Utilities/File
+Source: %{name}-%{version}.tar.gz
+Buildroot: %{_tmppath}/%{name}-%{version}-root
+BuildRequires: e2fsprogs-devel
+
+%description
+This package contains five programs -- delete, undelete, expunge,
+purge and lsdel.  "Delete" is intended to be a replacement for "rm" or
+"rmdir"; instead of actually deleting files and directories, it
+renames them with a ".#" prefix.  "Undelete" recovers deleted files,
+"expunge" removes previously deleted files, "purge" does the same
+thing but with less flexibility, and "lsdel" lists deleted files.  See
+the man pages for the various programs for additional information.
+
+%prep
+%setup
+
+%build
+rm -f configure.in
+cp rpm/* .
+# GNUconfigure macro looks for configure.in, not configure.ac, unfortunately
+mv configure.ac configure.in
+%{GNUconfigure}
+make all
+
+%install
+%{makeinstall}
+
+%changelog
+* Sat Mar 21 2009 Jonathan Kamens <jik@kamens.brookline.ma.us> - 10.0.0-1
+- Initial RPM release from Debathena source tree.
+
+%files
+%{_bindir}/delete
+%{_bindir}/undelete
+%{_bindir}/expunge
+%{_bindir}/purge
+%{_bindir}/lsdel
+%{_mandir}/man1/delete.1*
+%{_mandir}/man1/undelete.1*
+%{_mandir}/man1/expunge.1*
+%{_mandir}/man1/purge.1*
+%{_mandir}/man1/lsdel.1*
Index: expunge.c
===================================================================
--- expunge.c	(revision 23641)
+++ expunge.c	(working copy)
@@ -233,7 +233,7 @@
 		    }
 	       }
 	       else {
-		    set_error(ENOMATCH);
+		    set_error(DELETE_ENOMATCH);
 		    error(files[num - 1]);
 	       }
 	  }
@@ -263,11 +263,12 @@
 	  }
      }
      if (yield) {
-	  if (noop)
-	       printf("Total that would be expunged: %dk\n",
-		      space_to_k(space_removed));
-	  else
-	       printf("Total expunged: %dk\n", space_to_k(space_removed));
+       char *friendly = space_to_friendly(space_removed);
+       if (noop)
+	 printf("Total that would be expunged: %s\n", friendly);
+       else
+	 printf("Total expunged: %s\n", friendly);
+       free(friendly);
      }
      return status;
 }
@@ -375,8 +376,9 @@
      (void) convert_to_user_name(real, user);
 
      if (interactive) {
-	  printf ("%s: Expunge %s (%dk)? ", whoami, user,
-		  specs_to_k(file_ent->specs));
+       char *friendly = specs_to_friendly(file_ent->specs);
+       printf ("%s: Expunge %s (%s)? ", whoami, user, friendly);
+       free(friendly);
 	  if (! yes()) {
 	       set_status(EXPUNGE_NOT_EXPUNGED);
 	       return error_code;
@@ -385,9 +387,12 @@
 
      if (noop) {
 	  space_removed += specs_to_space(file_ent->specs);
-	  printf("%s: %s (%dk) would be expunged (%dk total)\n", whoami, user,
-		 specs_to_k(file_ent->specs),
-		 space_to_k(space_removed));
+	  char *friendly = space_to_friendly(space_removed);
+	  char *friendly2 = specs_to_friendly(file_ent->specs);
+	  printf("%s: %s (%s) would be expunged (%s total)\n", whoami, user,
+		 friendly2, friendly);
+	  free(friendly);
+	  free(friendly2);
 	  return 0;
      }
 
@@ -397,10 +402,14 @@
 	  status = unlink(real);
      if (! status) {
 	  space_removed += specs_to_space(file_ent->specs);
-	  if (verbose)
-	       printf("%s: %s (%dk) expunged (%dk total)\n", whoami, user,
-		      specs_to_k(file_ent->specs),
-		      space_to_k(space_removed));
+	  if (verbose) {
+	    char *friendly = space_to_friendly(space_removed);
+	    char *friendly2 = specs_to_friendly(file_ent->specs);
+	    printf("%s: %s (%s) expunged (%s total)\n", whoami, user,
+		   friendly2, friendly);
+	    free(friendly);
+	    free(friendly2);
+	  }
 	  return 0;
      }
      else {
Index: directories.c
===================================================================
--- directories.c	(revision 23641)
+++ directories.c	(working copy)
@@ -13,6 +13,7 @@
      static char rcsid_directories_c[] = "$Id: directories.c,v 1.28 1999-01-22 23:08:54 ghudson Exp $";
 #endif
 
+#include <math.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/param.h>
@@ -221,7 +222,7 @@
      specs->st_ino = realspecs.st_ino;
      specs->st_mode = realspecs.st_mode;
      specs->st_size = realspecs.st_size;
-     specs->st_chtime = realspecs.st_ctime;
+     specs->st_ctim = realspecs.st_ctime;
      specs->st_blocks = realspecs.st_blocks;
 
      return 0;
@@ -706,3 +707,38 @@
      *in_strings = strings;
      return 0;
 }
+
+char *bytes_to_friendly(off_t bytes)
+{
+  double size = bytes;
+  char *output;
+
+  size /= 1024;
+  if (size < 1024) {
+    if (! (output = malloc(7))) {
+      set_error(errno);
+      error("malloc");
+      return "";
+    }
+    sprintf(output, "%.0fKB", ceil(size));
+    return(output);
+  }
+  size /= 1024;
+  if (size < 1024) {
+    if (! (output = malloc(9))) {
+      set_error(errno);
+      error("malloc");
+      return "";
+    }
+    sprintf(output, "%.1fMB", size);
+    return(output);
+  }
+  size /= 1024;
+  if (! (output = malloc((int)log10(size)+6))) {
+    set_error(errno);
+    error("malloc");
+    return "";
+  }
+  sprintf(output, "%.2fGB", size);
+  return(output);
+}
Index: pattern.c
===================================================================
--- pattern.c	(revision 23641)
+++ pattern.c	(working copy)
@@ -40,16 +40,28 @@
  * lengths, merges the two into the first by realloc'ing the first and
  * then free's the second's memory usage.
  */  
-int add_arrays(array1, num1, array2, num2)
+int add_arrays(array1, num1, size1, array2, num2)
 char ***array1, ***array2;
-int *num1, *num2;
+int *num1, *size1, *num2;
 {
      int counter;
-     
+
+     if (! *size1) {
+       if (*array1)
+	 free(*array1);
+       *array1 = *array2;
+       *num1 = *num2;
+       *size1 = *num2;
+       return 0;
+     }
+
+     while (*size1 < (*num1 + *num2)) {
+       *size1 *= 2;
+     }
+
      *array1 = (char **) realloc((char *) *array1, (unsigned)
-				 (sizeof(char *) * (*num1 + *num2)));
-     if ((! *array1) && (*num1 + *num2))
-     {
+				 (sizeof(char *) * *size1));
+     if (! *array1) {
 	  set_error(errno);
 	  error("realloc");
 	  return error_code;
@@ -69,15 +81,27 @@
 /*
  * Add a string to a list of strings.
  */
-int add_str(strs, num, str)
+int add_str(strs, num, size, str)
 char ***strs;
-int num;
+int num, *size;
 char *str;
 {
      char **ary;
 
-     ary = *strs = (char **) realloc((char *) *strs, (unsigned)
-				     (sizeof(char *) * (num + 1)));
+     if (! *size) {
+       num = 0;
+       *size = 1;
+       ary = *strs = (char **) malloc((unsigned) (sizeof(char *)));
+     }
+     else if (num == *size) {
+       *size *= 2;
+       ary = *strs = (char **) realloc((char *) *strs, (unsigned)
+				       (sizeof(char *) * *size));
+     }
+     else {
+       ary = *strs;
+     }
+
      if (! *strs) {
 	  set_error(errno);
 	  error("realloc");
@@ -171,7 +195,7 @@
 {
      char 	**matched_files, **return_files, **recurs_files;
      int 	num_matched_files = 0, num_return_files = 0,
-                num_recurs_files = 0;
+                num_recurs_files = 0, return_files_size = 0;
      int	retval;
      int	i;
 #ifdef DEBUG
@@ -232,7 +256,8 @@
 
 	       if (num_recurs_files) {
 		    retval = add_arrays(&return_files, &num_return_files,
-					&recurs_files, &num_recurs_files);
+					&return_files_size, &recurs_files,
+					&num_recurs_files);
 		    if (retval) {
 			 error("add_arrays");
 			 return retval;
@@ -249,6 +274,7 @@
 	       if (is_deleted(lastpart(matched_files[i]))) {
 		    if (options & FIND_DELETED) {
 			 retval = add_str(&return_files, num_return_files,
+					  &return_files_size,
 					  matched_files[i]);
 			 if (retval) {
 			      error("add_str");
@@ -263,7 +289,7 @@
 	       }
 	       else if (options & FIND_UNDELETED) {
 		    retval = add_str(&return_files, num_return_files,
-				     matched_files[i]);
+				     &return_files_size, matched_files[i]);
 		    if (retval) {
 			 error("add_str");
 			 return retval;
@@ -406,7 +432,8 @@
 #ifdef PATTERN_DEBUG
      int j;
 #endif
-     
+     int found_size = 0;
+
 #ifdef DEBUG
      printf("do_match: looking for %s\n", name);
 #endif
@@ -435,7 +462,7 @@
      }
      (void) strcpy(first, firstpart(name, rest));
      if ((! *first) && (match_undeleted)) {
-	  retval = add_str(found, *num_found, base);
+	  retval = add_str(found, *num_found, &found_size, base);
 	  if (retval) {
 	       error("add_str");
 	       (void) popall();
@@ -511,7 +538,8 @@
 	  if (! *first) {
 	       if (is_deleted(lastpart(base))) {
 		    if (match_deleted) {
-			 retval = add_str(found, *num_found, base);
+			 retval = add_str(found, *num_found, &found_size,
+					  base);
 			 if (retval) {
 			      error("add_str");
 			      (void) popall();
@@ -524,7 +552,7 @@
 		    }
 	       }
 	       else if (match_undeleted) {
-		    retval = add_str(found, *num_found, base);
+		    retval = add_str(found, *num_found, &found_size, base);
 		    if (retval) {
 			 error("add_str");
 			 (void) popall();
@@ -745,6 +773,7 @@
      int strsize;
      struct stat statbuf;
      int use_stat;
+     int found_size = 0;
 
 #ifdef DEBUG
      fprintf(stderr, "do_recurs: opening %s\n", name);
@@ -762,6 +791,7 @@
 	  return error_code;
      }
 	 
+#ifdef S_IFLNK
      if (is_link(base, &statbuf)) {
 	  /* Never follow deleted symlinks */
 	  if (is_deleted(lastpart(base))) {
@@ -798,6 +828,7 @@
 	       }
 	  }
      }
+#endif
 
      if ((statbuf.st_mode & S_IFMT) != S_IFDIR)
 	  return 0;
@@ -823,7 +854,7 @@
 
 	  if (is_deleted(dp->d_name)) {
 	       if (options & FIND_DELETED) {
-		    retval = add_str(found, *num_found,
+		    retval = add_str(found, *num_found, &found_size,
 				     append(base, dp->d_name));
 		    if (retval) {
 			 error("add_str");
@@ -843,7 +874,7 @@
 	  if (options & FIND_UNDELETED) {
 	       if (is_dotfile(dp->d_name)) {
 		    if (options & FIND_DOTFILES) {
-			 retval = add_str(found, *num_found,
+			 retval = add_str(found, *num_found, &found_size,
 					  append(base, dp->d_name));
 			 if (retval) {
 			      error("add_str");
@@ -854,7 +885,7 @@
 		    continue;
 	       }
 	       else {
-		    retval = add_str(found, *num_found,
+		    retval = add_str(found, *num_found, &found_size,
 				     append(base, dp->d_name));
 		    if (retval) {
 			 error("add_str");
Index: util.c
===================================================================
--- util.c	(revision 23641)
+++ util.c	(working copy)
@@ -226,7 +226,7 @@
 filerec *file_ent;
 time_t current_time, min_days;
 {
-     if ((current_time - file_ent->specs.st_chtime) / 86400 >= min_days)
+     if ((current_time - file_ent->specs.st_ctim) / 86400 >= min_days)
 	  return(1);
      else
 	  return(0);
Index: rpm/configure.ac
===================================================================
--- rpm/configure.ac	(revision 0)
+++ rpm/configure.ac	(revision 0)
@@ -0,0 +1,16 @@
+AC_INIT([delete],[10.0.0])
+AM_INIT_AUTOMAKE([foreign])
+
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MKDIR_P
+
+AC_CHECK_LIB([m], [log10])
+
+PKG_CHECK_MODULES([delete], [com_err])
+PKG_CHECK_MODULES([undelete], [com_err])
+PKG_CHECK_MODULES([lsdel], [com_err])
+PKG_CHECK_MODULES([expunge], [com_err])
+
+AC_OUTPUT(Makefile)
Index: rpm/Makefile.am
===================================================================
--- rpm/Makefile.am	(revision 0)
+++ rpm/Makefile.am	(revision 0)
@@ -0,0 +1,36 @@
+bin_PROGRAMS	= delete undelete lsdel expunge
+
+SRCS1		= util.c util.h errors.c errors.h pattern.c pattern.h \
+		  stack.c stack.h shell_regexp.c shell_regexp.h
+SRCS2		= directories.c directories.h
+SRCS3		= col.c col.h
+
+delete_SOURCES	= delete.c delete.h ${SRCS1}
+nodist_delete_SOURCES = delete_errs.h delete_errs.c
+delete_LDADD	= ${delete_LIBS}
+
+undelete_SOURCES = undelete.c undelete.h ${SRCS1} ${SRCS2}
+nodist_undelete_SOURCES = delete_errs.h delete_errs.c
+undelete_LDADD	= ${delete_LIBS}
+
+lsdel_SOURCES	= lsdel.c lsdel.h ${SRCS1} ${SRCS2} ${SRCS3}
+nodist_lsdel_SOURCES = delete_errs.h delete_errs.c
+lsdel_LDADD	= ${delete_LIBS}
+
+expunge_SOURCES	= expunge.c expunge.h ${SRCS1} ${SRCS2} ${SRCS3}
+nodist_expunge_SOURCES = delete_errs.h delete_errs.c
+expunge_LDADD	= ${delete_LIBS}
+
+BUILT_SOURCES	= delete_errs.h delete_errs.c
+CLEANFILES	= delete_errs.h delete_errs.c
+
+delete_errs.h delete_errs.c:
+	compile_et ${srcdir}/delete_errs.et
+
+man_MANS	= man1/delete.1 man1/expunge.1 man1/lsdel.1 man1/purge.1 \
+		  man1/undelete.1
+
+install-exec-local:
+	rm -f ${DESTDIR}${bindir}/purge
+	${MKDIR_P} ${DESTDIR}${bindir}
+	${LN_S} expunge ${DESTDIR}${bindir}/purge
Index: directories.h
===================================================================
--- directories.h	(revision 23641)
+++ directories.h	(working copy)
@@ -15,10 +15,13 @@
 #define True			(Boolean) 1
 #define False			(Boolean) 0
 
+char *bytes_to_friendly(off_t);
 
 #define specs_to_space(x)	((x).st_blocks)
 #define space_to_k(x)		((x) / 2 + (((x) % 2) ? 1 : 0))
 #define specs_to_k(x)		space_to_k((x).st_blocks)
+#define space_to_friendly(x)	bytes_to_friendly((x))
+#define specs_to_friendly(x)	space_to_friendly((x).st_size)
 
 #define FOLLOW_LINKS		1
 #define DONT_FOLLOW_LINKS	0
@@ -31,7 +34,7 @@
      ino_t st_ino;
      unsigned short st_mode;
      off_t st_size;
-     time_t st_chtime;
+     time_t st_ctim;
      long st_blocks;
 } mystat;
 
@@ -54,6 +57,7 @@
 int add_file_to_parent();
 int add_path_to_tree();
 int find_child();
+int change_path();
 filerec *first_in_directory();
 filerec *first_specified_in_directory();
 filerec *get_cwd_tree();
Index: pattern.h
===================================================================
--- pattern.h	(revision 23641)
+++ pattern.h	(working copy)
@@ -10,8 +10,9 @@
  */
 #include "mit-copying.h"
 
-int add_str();
-int add_arrays();
+int add_str(char ***array, int array_count, int *array_size, char *string);
+int add_arrays(char ***array1, int *num1, int *size1, char ***array2,
+	       int *num2);
 int find_contents();
 int find_deleted_contents();
 int find_deleted_contents_recurs();
Index: delete_errs.et
===================================================================
--- delete_errs.et	(revision 23641)
+++ delete_errs.et	(working copy)
@@ -36,7 +36,7 @@
 	"can't find home directory"
 ec INTERNAL_ERROR,
 	"strange internal error"
-ec ENOMATCH,
+ec DELETE_ENOMATCH,
 	"no match"
 ec EXPUNGE_NOT_EXPUNGED,
 	""

--------------040503020203070208090505--

--=-EIv/icJd/ycjX1bT3XWI--


home help back first fref pref prev next nref lref last post