mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Remove create_dir function; use now-equivalent dm_create_dir instead.
* lib/misc/lvm-file.c (_create_dir_recursive, create_dir): Remove functions. * lib/misc/lvm-file.h (create_dir): Remove declaration. * lib/commands/toolcontext.c (create_toolcontext): s/create_dir/dm_create_dir/ * lib/format_text/archiver.c (archive, backup): Likewise. * lib/format_text/format-text.c (_add_dir): Likewise. * lib/locking/file_locking.c (init_file_locking): Likewise. Patch by Jun'ichi Nomura.
This commit is contained in:
parent
3f311f1daa
commit
941e4f5567
@ -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.
|
||||
|
@ -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 "
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user