Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Wow, you want to print out the raw errno number.
> 
> No, I didn't say that.  I wanted the strerror result, and that's what
> the code I suggested does.

OK, new version.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/port/dirmod.c
===================================================================
RCS file: /cvsroot/pgsql/src/port/dirmod.c,v
retrieving revision 1.34
diff -c -c -r1.34 dirmod.c
*** src/port/dirmod.c   31 Dec 2004 22:03:53 -0000      1.34
--- src/port/dirmod.c   13 Feb 2005 01:51:35 -0000
***************
*** 350,355 ****
--- 350,356 ----
        return filenames;
  }
  
+ 
  /*
   *    fnames_cleanup
   *
***************
*** 366,371 ****
--- 367,373 ----
        pfree(filenames);
  }
  
+ 
  /*
   *    rmtree
   *
***************
*** 398,413 ****
                snprintf(filepath, MAXPGPATH, "%s/%s", path, *filename);
  
                if (stat(filepath, &statbuf) != 0)
!               {
!                       fnames_cleanup(filenames);
!                       return false;
!               }
  
                if (S_ISDIR(statbuf.st_mode))
                {
                        /* call ourselves recursively for a directory */
                        if (!rmtree(filepath, true))
                        {
                                fnames_cleanup(filenames);
                                return false;
                        }
--- 400,413 ----
                snprintf(filepath, MAXPGPATH, "%s/%s", path, *filename);
  
                if (stat(filepath, &statbuf) != 0)
!                       goto report_and_fail;
  
                if (S_ISDIR(statbuf.st_mode))
                {
                        /* call ourselves recursively for a directory */
                        if (!rmtree(filepath, true))
                        {
+                               /* we already reported the error */
                                fnames_cleanup(filenames);
                                return false;
                        }
***************
*** 415,436 ****
                else
                {
                        if (unlink(filepath) != 0)
!                       {
!                               fnames_cleanup(filenames);
!                               return false;
!                       }
                }
        }
  
        if (rmtopdir)
        {
                if (rmdir(path) != 0)
!               {
!                       fnames_cleanup(filenames);
!                       return false;
!               }
        }
  
        fnames_cleanup(filenames);
        return true;
  }
--- 415,440 ----
                else
                {
                        if (unlink(filepath) != 0)
!                               goto report_and_fail;
                }
        }
  
        if (rmtopdir)
        {
                if (rmdir(path) != 0)
!                       goto report_and_fail;
        }
  
        fnames_cleanup(filenames);
        return true;
+ 
+ report_and_fail:
+ 
+ #ifndef FRONTEND
+       elog(WARNING, "can not remove \"%s\": %s", filepath, strerror(errno));
+ #else
+       fprintf(stderr, "can not remove \"%s\": %s\n", filepath, 
strerror(errno));
+ #endif
+       fnames_cleanup(filenames);
+       return false;
  }
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to