00001 /*- 00002 * See the file LICENSE for redistribution information. 00003 * 00004 * Copyright (c) 1997, 1998, 1999, 2000 00005 * Sleepycat Software. All rights reserved. 00006 */ 00007 00008 #include "config.h" 00009 00010 #ifndef lint 00011 static const char revid[] = "$Id: os__unlink_8c-source.html,v 1.1 2008年06月08日 10:21:34 sebdiaz Exp $"; 00012 #endif /* not lint */ 00013 00014 #ifndef NO_SYSTEM_INCLUDES 00015 #include <sys/types.h> 00016 00017 #include <errno.h> 00018 #include <string.h> 00019 #include <unistd.h> 00020 #endif 00021 00022 #include "db_int.h" 00023 #include "os_jump.h" 00024 00025 /* 00026 * CDB___os_unlink -- 00027 * Remove a file. 00028 * 00029 * PUBLIC: int CDB___os_unlink __P((DB_ENV *, const char *)); 00030 */ 00031 int 00032 CDB___os_unlink(dbenv, path) 00033 DB_ENV *dbenv; 00034 const char *path; 00035 { 00036 int ret; 00037 00038 ret = CDB___db_jump.j_unlink != NULL ? 00039 CDB___db_jump.j_unlink(path) : unlink(path); 00040 if (ret == -1) { 00041 ret = CDB___os_get_errno(); 00042 /* 00043 * XXX 00044 * We really shouldn't be looking at this value ourselves, 00045 * but ENOENT usually signals that a file is missing, and 00046 * we attempt to unlink things (such as v. 2.x environment 00047 * regions, in DB_ENV->remove) that we're expecting not to 00048 * be there. Reporting errors in these cases is annoying. 00049 */ 00050 #ifdef HAVE_VXWORKS 00051 /* 00052 * XXX 00053 * The results of unlink are file system driver specific 00054 * on VxWorks. In the case of removing a file that did 00055 * not exist, some, at least, return an error, but with 00056 * an errno of 0, not ENOENT. 00057 * 00058 * Code below falls through to original if-statement only 00059 * we didn't get a "successful" error. 00060 */ 00061 if (ret != 0) 00062 /* FALLTHROUGH */ 00063 #endif 00064 if (ret != ENOENT) 00065 CDB___db_err(dbenv, "Unlink: %s: %s", path, strerror(ret)); 00066 } 00067 00068 return (ret); 00069 }