⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_unlink.c

📁 File system using stacked.
💻 C
字号:
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 1997-2002 *	Sleepycat Software.  All rights reserved. */#include "db_config.h"#ifndef lintstatic const char revid[] = "$Id: os_unlink.c,v 1.1.1.1 2004/08/19 23:53:56 gopalan Exp $";#endif /* not lint */#ifndef __KERNEL__#ifndef NO_SYSTEM_INCLUDES#include <sys/types.h>#include <string.h>#include <unistd.h>#endif#else#include <linux/types.h>#include <linux/string.h>#include <linux/slab.h>#endif /* __KERNEL__ */#include "db_int.h"/* * __os_region_unlink -- *	Remove a shared memory object file. * * PUBLIC: int __os_region_unlink __P((DB_ENV *, const char *)); */int__os_region_unlink(dbenv, path)	DB_ENV *dbenv;	const char *path;{#ifdef HAVE_QNX	int ret;	char *newname;	if ((ret = __os_shmname(dbenv, path, &newname)) != 0)		goto err;	if ((ret = shm_unlink(newname)) != 0) {		ret = __os_get_errno();		if (ret != ENOENT)			__db_err(dbenv, "shm_unlink: %s: %s",			    newname, strerror(ret));	}err:	if (newname != NULL)		__os_free(dbenv, newname);	return (ret);#else	if (F_ISSET(dbenv, DB_ENV_OVERWRITE))		(void)__db_overwrite(dbenv, path);	return (__os_unlink(dbenv, path));#endif}#ifdef __KERNEL__int kdb3_unlink(const char * name){	int error = 0;	struct dentry *dentry;	struct nameidata nd;	        if(IS_ERR(name))		return PTR_ERR(name);		error = kdb3_path_lookup(name, LOOKUP_PARENT, &nd);	if (error)		goto exit;	error = -EISDIR;	if (nd.last_type != LAST_NORM)		goto exit1;	down(&nd.dentry->d_inode->i_sem);	dentry = lookup_hash(&nd.last, nd.dentry);	error = PTR_ERR(dentry);	if (!IS_ERR(dentry)) {		if (nd.last.name[nd.last.len])			goto slashes;		error = vfs_unlink(nd.dentry->d_inode, dentry);	exit2:		dput(dentry);	}	up(&nd.dentry->d_inode->i_sem);exit1:	path_release(&nd);exit:	return error;	slashes:         error = !dentry->d_inode ? -ENOENT :                 S_ISDIR(dentry->d_inode->i_mode) ? -EISDIR : -ENOTDIR;         goto exit2;}#endif/* * __os_unlink -- *	Remove a file. * * PUBLIC: int __os_unlink __P((DB_ENV *, const char *)); */int__os_unlink(dbenv, path)	DB_ENV *dbenv;	const char *path;{	int ret;retry:	ret = DB_GLOBAL(j_unlink) != NULL ?	    DB_GLOBAL(j_unlink)(path) :#ifdef HAVE_VXWORKS	    unlink((char *)path);#else#ifndef __KERNEL__	    unlink(path);#else	    kdb3_unlink(path);#endif#endif	if (ret == -1) {		if ((ret = __os_get_errno()) == EINTR)			goto retry;		/*		 * XXX		 * We really shouldn't be looking at this value ourselves,		 * but ENOENT usually signals that a file is missing, and		 * we attempt to unlink things (such as v. 2.x environment		 * regions, in DB_ENV->remove) that we're expecting not to		 * be there.  Reporting errors in these cases is annoying.		 */#ifdef HAVE_VXWORKS		/*		 * XXX		 * The results of unlink are file system driver specific		 * on VxWorks.  In the case of removing a file that did		 * not exist, some, at least, return an error, but with		 * an errno of 0, not ENOENT.		 *		 * Code below falls through to original if-statement only		 * we didn't get a "successful" error.		 */		if (ret != 0)		/* FALLTHROUGH */#endif#ifndef __KERNEL__		if (ret != ENOENT)			__db_err(dbenv, "unlink: %s: %s", path, strerror(ret));#endif	}	return (ret);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -