From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30307 invoked by alias); 21 Aug 2006 12:55:05 -0000 Received: (qmail 30225 invoked by uid 9447); 21 Aug 2006 12:55:00 -0000 Date: Mon, 21 Aug 2006 12:55:00 -0000 Message-ID: <20060821125500.30223.qmail@sourceware.org> From: agk@sourceware.org To: lvm2-cvs@sourceware.org Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ... Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2006-08/txt/msg00019.txt.bz2 List-Id: CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2006-08-21 12:54:54 Modified files: . : WHATS_NEW lib/activate : activate.c fs.c lib/commands : toolcontext.c lib/filters : filter-sysfs.c filter.c lib/format1 : import-export.c lib/format_text: archive.c archiver.c export.c format-text.c lib/locking : cluster_locking.c file_locking.c locking.c lib/log : log.c lib/metadata : lv_manip.c mirror.c lib/misc : lvm-file.c lvm-string.c lvm-string.h sharedlib.c lib/report : report.c tools : lvmcmdline.c lvresize.c toollib.c Log message: Move lvm_snprintf into libdevmapper. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.429&r2=1.430 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/fs.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-sysfs.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archive.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-file.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-string.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-string.h.diff?cvsroot=lvm2&r1=1.12&r2=1.13 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/sharedlib.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85 --- LVM2/WHATS_NEW 2006/08/21 12:04:54 1.429 +++ LVM2/WHATS_NEW 2006/08/21 12:54:51 1.430 @@ -1,6 +1,6 @@ Version 2.02.10 - ================================== - Move split_words() and split_dm_name() into libdevmapper. + Move lvm_snprintf(), split_words() and split_dm_name() into libdevmapper. Add lvconvert man page. Add mirror options to man pages. Prevent mirror renames. --- LVM2/lib/activate/activate.c 2006/08/08 21:20:00 1.112 +++ LVM2/lib/activate/activate.c 2006/08/21 12:54:51 1.113 @@ -39,7 +39,7 @@ { char path[PATH_MAX]; - if (lvm_snprintf(path, sizeof(path), "%s/lvm/global", cmd->proc_dir) + if (dm_snprintf(path, sizeof(path), "%s/lvm/global", cmd->proc_dir) < 0) { log_error("LVM1 proc global snprintf failed"); return 0; @@ -257,9 +257,9 @@ continue; } /* vgname/lvname */ - if (lvm_snprintf(path, sizeof(path), "%s/%s", lv->vg->name, + if (dm_snprintf(path, sizeof(path), "%s/%s", lv->vg->name, lv->name) < 0) { - log_error("lvm_snprintf error from %s/%s", lv->vg->name, + log_error("dm_snprintf error from %s/%s", lv->vg->name, lv->name); continue; } @@ -342,7 +342,7 @@ if (target_version(target_name, &maj, &min, &patchlevel)) return 1; - if (lvm_snprintf(module, sizeof(module), "dm-%s", target_name) + if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) { log_error("target_present module name too long: %s", target_name); --- LVM2/lib/activate/fs.c 2005/10/25 17:28:46 1.37 +++ LVM2/lib/activate/fs.c 2006/08/21 12:54:51 1.38 @@ -30,7 +30,7 @@ { char vg_path[PATH_MAX]; - if (lvm_snprintf(vg_path, sizeof(vg_path), "%s%s", + if (dm_snprintf(vg_path, sizeof(vg_path), "%s%s", dev_dir, vg_name) == -1) { log_error("Couldn't construct name of volume " "group directory."); @@ -53,7 +53,7 @@ { char vg_path[PATH_MAX]; - if (lvm_snprintf(vg_path, sizeof(vg_path), "%s%s", + if (dm_snprintf(vg_path, sizeof(vg_path), "%s%s", dev_dir, vg_name) == -1) { log_error("Couldn't construct name of volume " "group directory."); @@ -87,7 +87,7 @@ if (!strcmp(name, ".") || !strcmp(name, "..")) continue; - if (lvm_snprintf(path, sizeof(path), "%s/%s", dir, name) == -1) { + if (dm_snprintf(path, sizeof(path), "%s/%s", dir, name) == -1) { log_error("Couldn't create path for %s", name); continue; } @@ -109,28 +109,28 @@ char vg_path[PATH_MAX]; struct stat buf; - if (lvm_snprintf(vg_path, sizeof(vg_path), "%s%s", + if (dm_snprintf(vg_path, sizeof(vg_path), "%s%s", dev_dir, vg_name) == -1) { log_error("Couldn't create path for volume group dir %s", vg_name); return 0; } - if (lvm_snprintf(lv_path, sizeof(lv_path), "%s/%s", vg_path, + if (dm_snprintf(lv_path, sizeof(lv_path), "%s/%s", vg_path, lv_name) == -1) { log_error("Couldn't create source pathname for " "logical volume link %s", lv_name); return 0; } - if (lvm_snprintf(link_path, sizeof(link_path), "%s/%s", + if (dm_snprintf(link_path, sizeof(link_path), "%s/%s", dm_dir(), dev) == -1) { log_error("Couldn't create destination pathname for " "logical volume link for %s", lv_name); return 0; } - if (lvm_snprintf(lvm1_group_path, sizeof(lvm1_group_path), "%s/group", + if (dm_snprintf(lvm1_group_path, sizeof(lvm1_group_path), "%s/group", vg_path) == -1) { log_error("Couldn't create pathname for LVM1 group file for %s", vg_name); @@ -190,7 +190,7 @@ struct stat buf; char lv_path[PATH_MAX]; - if (lvm_snprintf(lv_path, sizeof(lv_path), "%s%s/%s", + if (dm_snprintf(lv_path, sizeof(lv_path), "%s%s/%s", dev_dir, vg_name, lv_name) == -1) { log_error("Couldn't determine link pathname."); return 0; --- LVM2/lib/commands/toolcontext.c 2006/08/18 21:17:18 1.40 +++ LVM2/lib/commands/toolcontext.c 2006/08/21 12:54:51 1.41 @@ -67,7 +67,7 @@ /* Set to "" to avoid using any system directory */ if ((e = getenv("LVM_SYSTEM_DIR"))) { - if (lvm_snprintf(cmd->sys_dir, sizeof(cmd->sys_dir), + if (dm_snprintf(cmd->sys_dir, sizeof(cmd->sys_dir), "%s", e) < 0) { log_error("LVM_SYSTEM_DIR environment variable " "is too long."); @@ -167,7 +167,7 @@ log_verbose("Set umask to %04o", cmd->default_settings.umask); /* dev dir */ - if (lvm_snprintf(cmd->dev_dir, sizeof(cmd->dev_dir), "%s/", + if (dm_snprintf(cmd->dev_dir, sizeof(cmd->dev_dir), "%s/", find_config_tree_str(cmd, "devices/dir", DEFAULT_DEV_DIR)) < 0) { log_error("Device directory given in config file too long"); @@ -178,7 +178,7 @@ #endif /* proc dir */ - if (lvm_snprintf(cmd->proc_dir, sizeof(cmd->proc_dir), "%s", + if (dm_snprintf(cmd->proc_dir, sizeof(cmd->proc_dir), "%s", find_config_tree_str(cmd, "global/proc", DEFAULT_PROC_DIR)) < 0) { log_error("Device directory given in config file too long"); @@ -319,7 +319,7 @@ if (*tag) filler = "_"; - if (lvm_snprintf(config_file, sizeof(config_file), "%s/lvm%s%s.conf", + if (dm_snprintf(config_file, sizeof(config_file), "%s/lvm%s%s.conf", cmd->sys_dir, filler, tag) < 0) { log_error("LVM_SYSTEM_DIR or tag was too long"); return 0; @@ -587,7 +587,7 @@ if (!(f3 = _init_filter_components(cmd))) return 0; - if (lvm_snprintf(cache_file, sizeof(cache_file), + if (dm_snprintf(cache_file, sizeof(cache_file), "%s/.cache", cmd->sys_dir) < 0) { log_error("Persistent cache filename too long ('%s/.cache').", cmd->sys_dir); @@ -839,7 +839,7 @@ min = (uint32_t) find_config_tree_int(cmd, "backup/retain_min", DEFAULT_ARCHIVE_NUMBER); - if (lvm_snprintf + if (dm_snprintf (default_dir, sizeof(default_dir), "%s/%s", cmd->sys_dir, DEFAULT_ARCHIVE_SUBDIR) == -1) { log_err("Couldn't create default archive path '%s/%s'.", @@ -860,7 +860,7 @@ find_config_tree_bool(cmd, "backup/backup", DEFAULT_BACKUP_ENABLED); - if (lvm_snprintf + if (dm_snprintf (default_dir, sizeof(default_dir), "%s/%s", cmd->sys_dir, DEFAULT_BACKUP_SUBDIR) == -1) { log_err("Couldn't create default backup path '%s/%s'.", --- LVM2/lib/filters/filter-sysfs.c 2006/08/21 12:04:55 1.12 +++ LVM2/lib/filters/filter-sysfs.c 2006/08/21 12:54:52 1.13 @@ -32,7 +32,7 @@ return 0; } - if (lvm_snprintf(proc_mounts, sizeof(proc_mounts), + if (dm_snprintf(proc_mounts, sizeof(proc_mounts), "%s/mounts", proc) < 0) { log_error("Failed to create /proc/mounts string"); return 0; @@ -46,7 +46,7 @@ while (fgets(buffer, sizeof(buffer), fp)) { if (dm_split_words(buffer, 4, 0, split) == 4 && !strcmp(split[2], "sysfs")) { - if (lvm_snprintf(path, len, "%s/%s", split[1], + if (dm_snprintf(path, len, "%s/%s", split[1], "block") >= 0) { r = 1; } @@ -183,7 +183,7 @@ if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) continue; - if (lvm_snprintf(path, sizeof(path), "%s/%s", dir, + if (dm_snprintf(path, sizeof(path), "%s/%s", dir, d->d_name) < 0) { log_error("sysfs path name too long: %s in %s", d->d_name, dir); --- LVM2/lib/filters/filter.c 2006/05/09 21:23:50 1.35 +++ LVM2/lib/filters/filter.c 2006/08/21 12:54:52 1.36 @@ -145,7 +145,7 @@ /* All types unrecognised initially */ memset(_max_partitions_by_major, 0, sizeof(int) * NUMBER_OF_MAJORS); - if (lvm_snprintf(proc_devices, sizeof(proc_devices), + if (dm_snprintf(proc_devices, sizeof(proc_devices), "%s/devices", proc) < 0) { log_error("Failed to create /proc/devices string"); return 0; --- LVM2/lib/format1/import-export.c 2006/05/10 17:49:25 1.82 +++ LVM2/lib/format1/import-export.c 2006/08/21 12:54:52 1.83 @@ -103,7 +103,7 @@ static int _system_id(struct cmd_context *cmd, char *s, const char *prefix) { - if (lvm_snprintf(s, NAME_LEN, "%s%s%lu", + if (dm_snprintf(s, NAME_LEN, "%s%s%lu", prefix, cmd->hostname, time(NULL)) < 0) { log_error("Generated system_id too long"); return 0; --- LVM2/lib/format_text/archive.c 2006/05/09 21:23:50 1.23 +++ LVM2/lib/format_text/archive.c 2006/08/21 12:54:52 1.24 @@ -277,7 +277,7 @@ } for (i = 0; i < 10; i++) { - if (lvm_snprintf(archive_name, sizeof(archive_name), + if (dm_snprintf(archive_name, sizeof(archive_name), "%s/%s_%05u.vg", dir, vg->name, ix) < 0) { log_error("Archive file name too long."); return 0; --- LVM2/lib/format_text/archiver.c 2006/04/12 21:23:04 1.4 +++ LVM2/lib/format_text/archiver.c 2006/08/21 12:54:52 1.5 @@ -190,7 +190,7 @@ return 0; } - if (lvm_snprintf(name, sizeof(name), "%s/%s", + if (dm_snprintf(name, sizeof(name), "%s/%s", vg->cmd->backup_params->dir, vg->name) < 0) { log_error("Failed to generate volume group metadata backup " "filename."); @@ -233,7 +233,7 @@ { char path[PATH_MAX]; - if (lvm_snprintf(path, sizeof(path), "%s/%s", + if (dm_snprintf(path, sizeof(path), "%s/%s", cmd->backup_params->dir, vg_name) < 0) { log_err("Failed to generate backup filename (for removal)."); return 0; @@ -342,7 +342,7 @@ { char path[PATH_MAX]; - if (lvm_snprintf(path, sizeof(path), "%s/%s", + if (dm_snprintf(path, sizeof(path), "%s/%s", cmd->backup_params->dir, vg_name) < 0) { log_err("Failed to generate backup filename (for restore)."); return 0; @@ -397,7 +397,7 @@ if ((vg->status & PARTIAL_VG) || (vg->status & EXPORTED_VG)) return; - if (lvm_snprintf(path, sizeof(path), "%s/%s", + if (dm_snprintf(path, sizeof(path), "%s/%s", vg->cmd->backup_params->dir, vg->name) < 0) { log_debug("Failed to generate backup filename."); return; --- LVM2/lib/format_text/export.c 2006/05/16 20:53:13 1.51 +++ LVM2/lib/format_text/export.c 2006/08/21 12:54:52 1.52 @@ -233,7 +233,7 @@ for (i = 0; (d > 1024.0) && _units[i]; i++) d /= 1024.0; - return lvm_snprintf(buffer, s, "# %g %s", d, _units[i]) > 0; + return dm_snprintf(buffer, s, "# %g %s", d, _units[i]) > 0; } /* @@ -623,7 +623,7 @@ pv = pvl->pv; /* FIXME But skip if there's already an LV called pv%d ! */ - if (lvm_snprintf(buffer, sizeof(buffer), "pv%d", count++) < 0) + if (dm_snprintf(buffer, sizeof(buffer), "pv%d", count++) < 0) return_0; if (!(name = dm_pool_strdup(f->mem, buffer))) --- LVM2/lib/format_text/format-text.c 2006/08/17 19:53:35 1.65 +++ LVM2/lib/format_text/format-text.c 2006/08/21 12:54:52 1.66 @@ -853,7 +853,7 @@ tmp != dirent->d_name + strlen(dirent->d_name) - 4)) { vgname = dirent->d_name; - if (lvm_snprintf(path, PATH_MAX, "%s/%s", + if (dm_snprintf(path, PATH_MAX, "%s/%s", dl->dir, vgname) < 0) { log_error("Name too long %s/%s", dl->dir, vgname); @@ -1533,7 +1533,7 @@ dir_list = &((struct mda_lists *) fmt->private)->dirs; list_iterate_items(dl, dir_list) { - if (lvm_snprintf(path, PATH_MAX, "%s/%s", + if (dm_snprintf(path, PATH_MAX, "%s/%s", dl->dir, vgname) < 0) { log_error("Name too long %s/%s", dl->dir, vgname); --- LVM2/lib/locking/cluster_locking.c 2006/06/12 09:46:35 1.13 +++ LVM2/lib/locking/cluster_locking.c 2006/08/21 12:54:52 1.14 @@ -398,9 +398,9 @@ case LCK_VG: /* If the VG name is empty then lock the unused PVs */ if (!*resource) - lvm_snprintf(lockname, sizeof(lockname), "P_orphans"); + dm_snprintf(lockname, sizeof(lockname), "P_orphans"); else - lvm_snprintf(lockname, sizeof(lockname), "V_%s", + dm_snprintf(lockname, sizeof(lockname), "V_%s", resource); cluster_cmd = CLVMD_CMD_LOCK_VG; --- LVM2/lib/locking/file_locking.c 2006/05/16 16:48:30 1.24 +++ LVM2/lib/locking/file_locking.c 2006/08/21 12:54:52 1.25 @@ -212,10 +212,10 @@ switch (flags & LCK_SCOPE_MASK) { case LCK_VG: if (!*resource) - lvm_snprintf(lockfile, sizeof(lockfile), + dm_snprintf(lockfile, sizeof(lockfile), "%s/P_orphans", _lock_dir); else - lvm_snprintf(lockfile, sizeof(lockfile), + dm_snprintf(lockfile, sizeof(lockfile), "%s/V_%s", _lock_dir, resource); if (!_lock_file(lockfile, flags)) --- LVM2/lib/locking/locking.c 2006/05/16 16:48:30 1.30 +++ LVM2/lib/locking/locking.c 2006/08/21 12:54:52 1.31 @@ -189,7 +189,7 @@ if (!*vgname) return 1; - if (lvm_snprintf(path, sizeof(path), "%s/lvm/VGs/%s", cmd->proc_dir, + if (dm_snprintf(path, sizeof(path), "%s/lvm/VGs/%s", cmd->proc_dir, vgname) < 0) { log_error("LVM1 proc VG pathname too long for %s", vgname); return 0; --- LVM2/lib/log/log.c 2006/08/01 14:56:33 1.34 +++ LVM2/lib/log/log.c 2006/08/21 12:54:53 1.35 @@ -318,7 +318,7 @@ log_it: if (!_log_suppress) { if (_verbose_level > _LOG_DEBUG) - lvm_snprintf(locn, sizeof(locn), "#%s:%d ", + dm_snprintf(locn, sizeof(locn), "#%s:%d ", file, line); else locn[0] = '\0'; @@ -413,7 +413,7 @@ _already_logging = 1; memset(&buf, ' ', sizeof(buf)); bufused = 0; - if ((n = lvm_snprintf(buf, sizeof(buf) - bufused - 1, + if ((n = dm_snprintf(buf, sizeof(buf) - bufused - 1, "%s:%d %s%s", file, line, _cmd_name, _msg_prefix)) == -1) goto done; --- LVM2/lib/metadata/lv_manip.c 2006/05/11 18:54:04 1.99 +++ LVM2/lib/metadata/lv_manip.c 2006/08/21 12:54:53 1.100 @@ -1240,7 +1240,7 @@ high = i; } - if (lvm_snprintf(buffer, len, format, high + 1) < 0) + if (dm_snprintf(buffer, len, format, high + 1) < 0) return NULL; return buffer; --- LVM2/lib/metadata/mirror.c 2006/07/20 20:37:10 1.31 +++ LVM2/lib/metadata/mirror.c 2006/08/21 12:54:53 1.32 @@ -428,7 +428,7 @@ return 0; } - if (lvm_snprintf(img_name, len, "%s_mimage_%%d", lv->name) < 0) { + if (dm_snprintf(img_name, len, "%s_mimage_%%d", lv->name) < 0) { log_error("img_name allocation failed. " "Remove new LV and retry."); return 0; --- LVM2/lib/misc/lvm-file.c 2006/05/09 21:23:50 1.15 +++ LVM2/lib/misc/lvm-file.c 2006/08/21 12:54:53 1.16 @@ -50,7 +50,7 @@ for (i = 0; i < 20; i++, num++) { - if (lvm_snprintf(buffer, len, "%s/.lvm_%s_%d_%d", + if (dm_snprintf(buffer, len, "%s/.lvm_%s_%d_%d", dir, hostname, pid, num) == -1) { log_err("Not enough space to build temporary file " "string."); --- LVM2/lib/misc/lvm-string.c 2006/08/21 12:04:55 1.11 +++ LVM2/lib/misc/lvm-string.c 2006/08/21 12:54:53 1.12 @@ -14,30 +14,9 @@ */ #include "lib.h" -#include "lvm-types.h" #include "lvm-string.h" -/* - * On error, up to glibc 2.0.6, snprintf returned -1 if buffer was too small; - * From glibc 2.1 it returns number of chars (excl. trailing null) that would - * have been written had there been room. - * - * lvm_snprintf reverts to the old behaviour. - */ -int lvm_snprintf(char *buf, size_t bufsize, const char *format, ...) -{ - int n; - va_list ap; - - va_start(ap, format); - n = vsnprintf(buf, bufsize, format, ap); - va_end(ap); - - if (n < 0 || (n > bufsize - 1)) - return -1; - - return n; -} +#include int emit_to_buffer(char **buffer, size_t *size, const char *fmt, ...) { --- LVM2/lib/misc/lvm-string.h 2006/08/21 12:04:55 1.12 +++ LVM2/lib/misc/lvm-string.h 2006/08/21 12:54:53 1.13 @@ -23,15 +23,6 @@ struct pool; -/* - * On error, up to glibc 2.0.6, snprintf returned -1 if buffer was too small; - * From glibc 2.1 it returns number of chars (excl. trailing null) that would - * have been written had there been room. - * - * lvm_snprintf reverts to the old behaviour. - */ -int lvm_snprintf(char *buf, size_t bufsize, const char *format, ...); - int emit_to_buffer(char **buffer, size_t *size, const char *fmt, ...); char *build_dm_name(struct dm_pool *mem, const char *vg, --- LVM2/lib/misc/sharedlib.c 2006/07/05 17:26:36 1.11 +++ LVM2/lib/misc/sharedlib.c 2006/08/21 12:54:53 1.12 @@ -32,7 +32,7 @@ * if present */ if (libname[0] == '/' || !(lib_dir = find_config_tree_str(cmd, "global/library_dir", 0)) || - (lvm_snprintf(path, path_len, "%s/%s", lib_dir, + (dm_snprintf(path, path_len, "%s/%s", lib_dir, libname) == -1) || stat(path, &info) == -1) strncpy(path, libname, path_len); } --- LVM2/lib/report/report.c 2006/05/11 20:17:17 1.46 +++ LVM2/lib/report/report.c 2006/08/21 12:54:53 1.47 @@ -172,9 +172,9 @@ return 0; } - if (lvm_snprintf(extent_str, sizeof(extent_str), "(%" PRIu32 + if (dm_snprintf(extent_str, sizeof(extent_str), "(%" PRIu32 ")", extent) < 0) { - log_error("Extent number lvm_snprintf failed"); + log_error("Extent number dm_snprintf failed"); return 0; } @@ -276,7 +276,7 @@ return 0; } - if (lvm_snprintf(repstr, 12, "%d", value) < 0) { + if (dm_snprintf(repstr, 12, "%d", value) < 0) { log_error("int too big: %d", value); return 0; } @@ -540,7 +540,7 @@ return 0; } - if (lvm_snprintf(repstr, len, "[%s]", lv->name) < 0) { + if (dm_snprintf(repstr, len, "[%s]", lv->name) < 0) { log_error("lvname snprintf failed"); return 0; } @@ -784,7 +784,7 @@ return 0; } - if (lvm_snprintf(repstr, 11, "%u", value) < 0) { + if (dm_snprintf(repstr, 11, "%u", value) < 0) { log_error("uint32 too big: %u", value); return 0; } @@ -813,7 +813,7 @@ return 0; } - if (lvm_snprintf(repstr, 12, "%d", value) < 0) { + if (dm_snprintf(repstr, 12, "%d", value) < 0) { log_error("int32 too big: %d", value); return 0; } @@ -870,7 +870,7 @@ return 0; } - if (lvm_snprintf(repstr, 7, "%.2f", snap_percent) < 0) { + if (dm_snprintf(repstr, 7, "%.2f", snap_percent) < 0) { log_error("snapshot percentage too large"); return 0; } @@ -910,7 +910,7 @@ return 0; } - if (lvm_snprintf(repstr, 7, "%.2f", percent) < 0) { + if (dm_snprintf(repstr, 7, "%.2f", percent) < 0) { log_error("copy percentage too large"); return 0; } @@ -1324,7 +1324,7 @@ heading = _fields[fp->field_num].heading; if (rh->flags & RH_ALIGNED) { - if (lvm_snprintf(buf, sizeof(buf), "%-*.*s", + if (dm_snprintf(buf, sizeof(buf), "%-*.*s", fp->width, fp->width, heading) < 0) { log_error("snprintf heading failed"); dm_pool_end_object(rh->mem); @@ -1467,7 +1467,7 @@ strlen(repstr))) goto bad; } else if (field->props->flags & FLD_ALIGN_LEFT) { - if (lvm_snprintf(buf, sizeof(buf), "%-*.*s", + if (dm_snprintf(buf, sizeof(buf), "%-*.*s", width, width, repstr) < 0) { log_error("snprintf repstr failed"); dm_pool_end_object(rh->mem); @@ -1476,7 +1476,7 @@ if (!dm_pool_grow_object(rh->mem, buf, width)) goto bad; } else if (field->props->flags & FLD_ALIGN_RIGHT) { - if (lvm_snprintf(buf, sizeof(buf), "%*.*s", + if (dm_snprintf(buf, sizeof(buf), "%*.*s", width, width, repstr) < 0) { log_error("snprintf repstr failed"); dm_pool_end_object(rh->mem); --- LVM2/tools/lvmcmdline.c 2006/08/18 21:17:18 1.33 +++ LVM2/tools/lvmcmdline.c 2006/08/21 12:54:53 1.34 @@ -1188,7 +1188,7 @@ { char *e = getenv("HOME"); - if (lvm_snprintf(buffer, size, "%s/.lvm_history", e) < 0) { + if (dm_snprintf(buffer, size, "%s/.lvm_history", e) < 0) { log_error("$HOME/.lvm_history: path too long"); return 0; } @@ -1311,7 +1311,7 @@ { char path[PATH_MAX]; - if (lvm_snprintf(path, sizeof(path), "%s.lvm1", argv[0]) < 0) { + if (dm_snprintf(path, sizeof(path), "%s.lvm1", argv[0]) < 0) { log_error("Failed to create LVM1 tool pathname"); return; } --- LVM2/tools/lvresize.c 2006/05/16 16:48:31 1.73 +++ LVM2/tools/lvresize.c 2006/08/21 12:54:53 1.74 @@ -480,14 +480,14 @@ } if (lp->resizefs) { - if (lvm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir, + if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir, lp->vg_name, lp->lv_name) < 0) { log_error("Couldn't create LV path for %s", lp->lv_name); return ECMD_FAILED; } - if (lvm_snprintf(size_buf, SIZE_BUF, "%" PRIu64, + if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64, (uint64_t) lp->extents * vg->extent_size / 2) < 0) { log_error("Couldn't generate new LV size string"); --- LVM2/tools/toollib.c 2006/06/14 20:27:15 1.84 +++ LVM2/tools/toollib.c 2006/08/21 12:54:53 1.85 @@ -268,7 +268,7 @@ } else { vglv_sz = strlen(vgname) + strlen(lv_name) + 2; if (!(vglv = dm_pool_alloc(cmd->mem, vglv_sz)) || - lvm_snprintf(vglv, vglv_sz, "%s/%s", vgname, + dm_snprintf(vglv, vglv_sz, "%s/%s", vgname, lv_name) < 0) { log_error("vg/lv string alloc failed"); return ECMD_FAILED; @@ -1098,14 +1098,14 @@ int generate_log_name_format(struct volume_group *vg __attribute((unused)), const char *lv_name, char *buffer, size_t size) { - if (lvm_snprintf(buffer, size, "%s_mlog", lv_name) < 0) { + if (dm_snprintf(buffer, size, "%s_mlog", lv_name) < 0) { stack; return 0; } /* FIXME I think we can cope without this. Cf. _add_lv_to_dtree() if (find_lv_in_vg(vg, buffer) && - lvm_snprintf(buffer, size, "%s_mlog_%%d", + dm_snprintf(buffer, size, "%s_mlog_%%d", lv_name) < 0) { stack; return 0; @@ -1135,7 +1135,7 @@ return 0; } - if (lvm_snprintf(name, PATH_MAX, "%s%s/%s", cmd->dev_dir, + if (dm_snprintf(name, PATH_MAX, "%s%s/%s", cmd->dev_dir, lv->vg->name, lv->name) < 0) { log_error("Name too long - device not cleared (%s)", lv->name); return 0; @@ -1183,7 +1183,7 @@ return 0; } - if (lvm_snprintf(name, PATH_MAX, "%s%s/%s", cmd->dev_dir, + if (dm_snprintf(name, PATH_MAX, "%s%s/%s", cmd->dev_dir, lv->vg->name, lv->name) < 0) { log_error("Name too long - log header not written (%s)", lv->name); return 0;