From 36f82d943323f5597dedc320de6e7a1302c6dde5 Mon Sep 17 00:00:00 2001 From: Xuefer Date: Mon, 5 Jun 2006 05:13:34 +0000 Subject: [PATCH] refix to unlink correctly for newly created files git-svn-id: svn://svn.lighttpd.net/xcache/trunk@61 c26eb9a1-5813-0410-bd6c-c2e55f420ca7 --- mmap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mmap.c b/mmap.c index 9a87e59..b10612e 100644 --- a/mmap.c +++ b/mmap.c @@ -166,15 +166,16 @@ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_pr # define XCACHE_MMAP_PERMISSION (S_IRUSR | S_IWUSR) fd = open(shm->name, O_RDWR, XCACHE_MMAP_PERMISSION); if (fd == -1) { + /* do not create file in /dev */ + if (strncmp(shm->name, "/dev", 4) == 0) { + goto err; + } fd = open(shm->name, O_CREAT | O_RDWR, XCACHE_MMAP_PERMISSION); shm->newfile = 1; if (fd == -1) { goto err; } } - if (strncmp(shm->name, "/tmp", 4) == 0) { - shm->newfile = 0; - } ftruncate(fd, size); #endif