Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

os_unlink.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: os_unlink.c,v 12.3 2005/08/10 15:47:27 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 
00015 #include <string.h>
00016 #endif
00017 
00018 #include "db_int.h"
00019 
00020 /*
00021  * __os_region_unlink --
00022  *      Remove a shared memory object file.
00023  *
00024  * PUBLIC: int __os_region_unlink __P((DB_ENV *, const char *));
00025  */
00026 int
00027 __os_region_unlink(dbenv, path)
00028         DB_ENV *dbenv;
00029         const char *path;
00030 {
00031 #ifdef HAVE_QNX
00032         int ret;
00033         char *newname;
00034 
00035         if ((ret = __os_shmname(dbenv, path, &newname)) != 0)
00036                 goto err;
00037 
00038         if ((ret = shm_unlink(newname)) != 0) {
00039                 ret = __os_get_errno();
00040                 if (ret != ENOENT)
00041                         __db_err(dbenv, "shm_unlink: %s: %s",
00042                             newname, strerror(ret));
00043         }
00044 err:
00045         if (newname != NULL)
00046                 __os_free(dbenv, newname);
00047         return (ret);
00048 #else
00049         if (F_ISSET(dbenv, DB_ENV_OVERWRITE))
00050                 (void)__db_file_multi_write(dbenv, path);
00051 
00052         return (__os_unlink(dbenv, path));
00053 #endif
00054 }
00055 
00056 /*
00057  * __os_unlink --
00058  *      Remove a file.
00059  *
00060  * PUBLIC: int __os_unlink __P((DB_ENV *, const char *));
00061  */
00062 int
00063 __os_unlink(dbenv, path)
00064         DB_ENV *dbenv;
00065         const char *path;
00066 {
00067         int ret;
00068 
00069         if (DB_GLOBAL(j_unlink) != NULL)
00070                 ret = DB_GLOBAL(j_unlink)(path);
00071         else
00072 #ifdef HAVE_VXWORKS
00073             RETRY_CHK((unlink((char *)path)), ret);
00074 #else
00075             RETRY_CHK((unlink(path)), ret);
00076 #endif
00077         /*
00078          * !!!
00079          * The results of unlink are file system driver specific on VxWorks.
00080          * In the case of removing a file that did not exist, some, at least,
00081          * return an error, but with an errno of 0, not ENOENT.  We do not
00082          * have to test for the explicitly, the RETRY_CHK macro resets "ret"
00083          * to be the errno, and so we'll just slide right on through.
00084          *
00085          * XXX
00086          * We shouldn't be testing for an errno of ENOENT here, but ENOENT
00087          * signals that a file is missing, and we attempt to unlink things
00088          * (such as v. 2.x environment regions, in DB_ENV->remove) that we
00089          * are expecting not to be there.  Reporting errors in these cases
00090          * is annoying.
00091          */
00092         if (ret != 0 && ret != ENOENT)
00093                 __db_err(dbenv, "unlink: %s: %s", path, strerror(ret));
00094 
00095         return (ret);
00096 }

Generated on Sun Dec 25 12:14:42 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2