~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to bdb/os/os_unlink.c

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
VirginĀ 5.0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-
 
2
 * See the file LICENSE for redistribution information.
 
3
 *
 
4
 * Copyright (c) 1997-2002
 
5
 *      Sleepycat Software.  All rights reserved.
 
6
 */
 
7
 
 
8
#include "db_config.h"
 
9
 
 
10
#ifndef lint
 
11
static const char revid[] = "$Id: os_unlink.c,v 11.24 2002/07/12 18:56:53 bostic Exp $";
 
12
#endif /* not lint */
 
13
 
 
14
#ifndef NO_SYSTEM_INCLUDES
 
15
#include <sys/types.h>
 
16
 
 
17
#include <string.h>
 
18
#include <unistd.h>
 
19
#endif
 
20
 
 
21
#include "db_int.h"
 
22
 
 
23
/*
 
24
 * __os_region_unlink --
 
25
 *      Remove a shared memory object file.
 
26
 *
 
27
 * PUBLIC: int __os_region_unlink __P((DB_ENV *, const char *));
 
28
 */
 
29
int
 
30
__os_region_unlink(dbenv, path)
 
31
        DB_ENV *dbenv;
 
32
        const char *path;
 
33
{
 
34
#ifdef HAVE_QNX
 
35
        int ret;
 
36
        char *newname;
 
37
 
 
38
        if ((ret = __os_shmname(dbenv, path, &newname)) != 0)
 
39
                goto err;
 
40
 
 
41
        if ((ret = shm_unlink(newname)) != 0) {
 
42
                ret = __os_get_errno();
 
43
                if (ret != ENOENT)
 
44
                        __db_err(dbenv, "shm_unlink: %s: %s",
 
45
                            newname, strerror(ret));
 
46
        }
 
47
err:
 
48
        if (newname != NULL)
 
49
                __os_free(dbenv, newname);
 
50
        return (ret);
 
51
#else
 
52
        if (F_ISSET(dbenv, DB_ENV_OVERWRITE))
 
53
                (void)__db_overwrite(dbenv, path);
 
54
 
 
55
        return (__os_unlink(dbenv, path));
 
56
#endif
 
57
}
 
58
 
 
59
/*
 
60
 * __os_unlink --
 
61
 *      Remove a file.
 
62
 *
 
63
 * PUBLIC: int __os_unlink __P((DB_ENV *, const char *));
 
64
 */
 
65
int
 
66
__os_unlink(dbenv, path)
 
67
        DB_ENV *dbenv;
 
68
        const char *path;
 
69
{
 
70
        int ret;
 
71
 
 
72
retry:  ret = DB_GLOBAL(j_unlink) != NULL ?
 
73
            DB_GLOBAL(j_unlink)(path) :
 
74
#ifdef HAVE_VXWORKS
 
75
            unlink((char *)path);
 
76
#else
 
77
            unlink(path);
 
78
#endif
 
79
        if (ret == -1) {
 
80
                if ((ret = __os_get_errno()) == EINTR)
 
81
                        goto retry;
 
82
                /*
 
83
                 * XXX
 
84
                 * We really shouldn't be looking at this value ourselves,
 
85
                 * but ENOENT usually signals that a file is missing, and
 
86
                 * we attempt to unlink things (such as v. 2.x environment
 
87
                 * regions, in DB_ENV->remove) that we're expecting not to
 
88
                 * be there.  Reporting errors in these cases is annoying.
 
89
                 */
 
90
#ifdef HAVE_VXWORKS
 
91
                /*
 
92
                 * XXX
 
93
                 * The results of unlink are file system driver specific
 
94
                 * on VxWorks.  In the case of removing a file that did
 
95
                 * not exist, some, at least, return an error, but with
 
96
                 * an errno of 0, not ENOENT.
 
97
                 *
 
98
                 * Code below falls through to original if-statement only
 
99
                 * we didn't get a "successful" error.
 
100
                 */
 
101
                if (ret != 0)
 
102
                /* FALLTHROUGH */
 
103
#endif
 
104
                if (ret != ENOENT)
 
105
                        __db_err(dbenv, "unlink: %s: %s", path, strerror(ret));
 
106
        }
 
107
 
 
108
        return (ret);
 
109
}