1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1997,2008 Oracle. All rights reserved. 5 * 6 * $Id: os_mkdir.c,v 12.24 2008/01/11 20:50:01 bostic Exp $ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12 13/* 14 * __os_mkdir -- 15 * Create a directory. 16 * 17 * PUBLIC: int __os_mkdir __P((ENV *, const char *, int)); 18 */ 19int 20__os_mkdir(env, name, mode) 21 ENV *env; 22 const char *name; 23 int mode; 24{ 25 DB_ENV *dbenv; 26 int ret; 27 28 dbenv = env == NULL ? NULL : env->dbenv; 29 if (dbenv != NULL && 30 FLD_ISSET(dbenv->verbose, DB_VERB_FILEOPS | DB_VERB_FILEOPS_ALL)) 31 __db_msg(env, "fileops: mkdir %s", name); 32 33 /* Make the directory, with paranoid permissions. */ 34#if defined(HAVE_VXWORKS) 35 RETRY_CHK((mkdir(CHAR_STAR_CAST name)), ret); 36#else 37 RETRY_CHK((mkdir(name, DB_MODE_700)), ret); 38#endif 39 if (ret != 0) 40 return (__os_posix_err(ret)); 41 42 /* Set the absolute permissions, if specified. */ 43#if !defined(HAVE_VXWORKS) 44 if (mode != 0) { 45 RETRY_CHK((chmod(name, mode)), ret); 46 if (ret != 0) 47 ret = __os_posix_err(ret); 48 } 49#endif 50 return (ret); 51} 52