diff --git a/WHATS_NEW b/WHATS_NEW index bead634a6..44b1e989b 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.28 - ================================ + Remove create_dir function; use now-equivalent dm_create_dir instead Detect stream write failure reliably; new fn: lvm_fclose; use dm_fclose Fix clvmd if compiled with gulm support. (2.02.26) Trivial fix to lvdisplay man page. diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 37cc314df..763831193 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -939,7 +939,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, goto error; /* Create system directory if it doesn't already exist */ - if (*cmd->sys_dir && !create_dir(cmd->sys_dir)) { + if (*cmd->sys_dir && !dm_create_dir(cmd->sys_dir)) { log_error("Failed to create LVM2 system dir for metadata backups, config " "files and internal cache."); log_error("Set environment variable LVM_SYSTEM_DIR to alternative location " diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c index 5fa3128ec..4482a4821 100644 --- a/lib/format_text/archiver.c +++ b/lib/format_text/archiver.c @@ -117,7 +117,7 @@ int archive(struct volume_group *vg) return 1; } - if (!create_dir(vg->cmd->archive_params->dir)) + if (!dm_create_dir(vg->cmd->archive_params->dir)) return 0; /* Trap a read-only file system */ @@ -223,7 +223,7 @@ int backup(struct volume_group *vg) return 1; } - if (!create_dir(vg->cmd->backup_params->dir)) + if (!dm_create_dir(vg->cmd->backup_params->dir)) return 0; /* Trap a read-only file system */ diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 05ee7986c..1a24e5ae3 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -1856,7 +1856,7 @@ static int _add_dir(const char *dir, struct list *dir_list) { struct dir_list *dl; - if (create_dir(dir)) { + if (dm_create_dir(dir)) { if (!(dl = dm_malloc(sizeof(struct list) + strlen(dir) + 1))) { log_error("_add_dir allocation failed"); return 0; diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c index 7361a78d4..e734a1ead 100644 --- a/lib/locking/file_locking.c +++ b/lib/locking/file_locking.c @@ -284,7 +284,7 @@ int init_file_locking(struct locking_type *locking, struct cmd_context *cmd) DEFAULT_LOCK_DIR), sizeof(_lock_dir)); - if (!create_dir(_lock_dir)) + if (!dm_create_dir(_lock_dir)) return 0; /* Trap a read-only file system */ diff --git a/lib/misc/lvm-file.c b/lib/misc/lvm-file.c index 339f32d72..caaebbea5 100644 --- a/lib/misc/lvm-file.c +++ b/lib/misc/lvm-file.c @@ -140,56 +140,6 @@ int dir_exists(const char *path) return 1; } -static int _create_dir_recursive(const char *dir) -{ - char *orig, *s; - int rc; - - log_verbose("Creating directory \"%s\"", dir); - /* Create parent directories */ - orig = s = dm_strdup(dir); - while ((s = strchr(s, '/')) != NULL) { - *s = '\0'; - if (*orig) { - rc = mkdir(orig, 0777); - if (rc < 0 && errno != EEXIST) { - if (errno != EROFS) - log_sys_error("mkdir", orig); - dm_free(orig); - return 0; - } - } - *s++ = '/'; - } - dm_free(orig); - - /* Create final directory */ - rc = mkdir(dir, 0777); - if (rc < 0 && errno != EEXIST) { - if (errno != EROFS) - log_sys_error("mkdir", dir); - return 0; - } - return 1; -} - -int create_dir(const char *dir) -{ - struct stat info; - - if (!*dir) - return 1; - - if (stat(dir, &info) < 0) - return _create_dir_recursive(dir); - - if (S_ISDIR(info.st_mode)) - return 1; - - log_error("Directory \"%s\" not found", dir); - return 0; -} - int is_empty_dir(const char *dir) { struct dirent *dirent; @@ -273,7 +223,7 @@ int fcntl_lock_file(const char *file, short lock_type, int warn_if_read_only) if ((c = strrchr(dir, '/'))) *c = '\0'; - if (!create_dir(dir)) { + if (!dm_create_dir(dir)) { dm_free(dir); return -1; } diff --git a/lib/misc/lvm-file.h b/lib/misc/lvm-file.h index a0ff41d35..f678afce1 100644 --- a/lib/misc/lvm-file.h +++ b/lib/misc/lvm-file.h @@ -39,12 +39,6 @@ int dir_exists(const char *path); */ int is_empty_dir(const char *dir); -/* - * Create directory (recursively) if necessary. Return 1 - * if directory was successfully created (or already exists), else 0. - */ -int create_dir(const char *dir); - /* Sync directory changes */ void sync_dir(const char *file);