public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/libdm libdm-common.c
@ 2009-09-25 18:19 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2009-09-25 18:19 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2009-09-25 18:19:09
Modified files:
libdm : libdm-common.c
Log message:
ensure dm_strdup succeeds
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84
--- LVM2/libdm/libdm-common.c 2009/09/25 18:13:17 1.83
+++ LVM2/libdm/libdm-common.c 2009/09/25 18:19:09 1.84
@@ -217,7 +217,9 @@
continue;
if (buf.st_rdev == st_rdev) {
- new_name = dm_strdup(name);
+ if (!(new_name = dm_strdup(name)))
+ log_error("dm_task_set_name: strdup(%s) failed",
+ name);
break;
}
}
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2012-02-13 14:39 zkabelac
0 siblings, 0 replies; 21+ messages in thread
From: zkabelac @ 2012-02-13 14:39 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-02-13 14:39:24
Modified files:
libdm : libdm-common.c
Log message:
Fix missing temp_buf init for error path
In previous commit this was missing, also deallocate in reversed order.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.137&r2=1.138
--- LVM2/libdm/libdm-common.c 2012/02/13 10:49:28 1.137
+++ LVM2/libdm/libdm-common.c 2012/02/13 14:39:24 1.138
@@ -1188,7 +1188,7 @@
static int _sysfs_get_dm_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size)
{
- char *sysfs_path, *temp_buf;
+ char *sysfs_path, *temp_buf = NULL;
FILE *fp = NULL;
int r = 0;
size_t len;
@@ -1232,15 +1232,15 @@
if (fp && fclose(fp))
log_sys_error("fclose", sysfs_path);
- dm_free(sysfs_path);
dm_free(temp_buf);
+ dm_free(sysfs_path);
return r;
}
static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size)
{
- char *sysfs_path, *temp_buf, *name;
+ char *name, *sysfs_path, *temp_buf = NULL;
ssize_t size;
size_t len;
int r = 0;
@@ -1281,8 +1281,8 @@
strcpy(buf, name);
r = 1;
bad:
- dm_free(sysfs_path);
dm_free(temp_buf);
+ dm_free(sysfs_path);
return r;
}
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2012-01-25 21:47 zkabelac
0 siblings, 0 replies; 21+ messages in thread
From: zkabelac @ 2012-01-25 21:47 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-25 21:47:18
Modified files:
libdm : libdm-common.c
Log message:
Fix resource leak of file handle
Introduces when added dm_device_get_name.
Close file handle in all error paths.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134
--- LVM2/libdm/libdm-common.c 2012/01/17 14:36:58 1.133
+++ LVM2/libdm/libdm-common.c 2012/01/25 21:47:18 1.134
@@ -1189,7 +1189,8 @@
static int _sysfs_get_dm_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size)
{
char *sysfs_path, *temp_buf;
- FILE *fp;
+ FILE *fp = NULL;
+ int r = 0;
if (!(sysfs_path = dm_malloc(PATH_MAX)) ||
!(temp_buf = dm_malloc(PATH_MAX))) {
@@ -1219,23 +1220,21 @@
}
temp_buf[strlen(temp_buf) - 1] = '\0';
- if (fclose(fp))
- log_sys_error("fclose", sysfs_path);
-
if (buf_size < strlen(temp_buf) + 1) {
log_error("_sysfs_get_dm_name: supplied buffer too small");
goto error;
}
strncpy(buf, temp_buf, buf_size);
- dm_free(sysfs_path);
- dm_free(temp_buf);
- return 1;
-
+ r = 1;
error:
+ if (fp && fclose(fp))
+ log_sys_error("fclose", sysfs_path);
+
dm_free(sysfs_path);
dm_free(temp_buf);
- return 0;
+
+ return r;
}
static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size)
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2011-09-24 11:47 prajnoha
0 siblings, 0 replies; 21+ messages in thread
From: prajnoha @ 2011-09-24 11:47 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2011-09-24 11:47:53
Modified files:
libdm : libdm-common.c
Log message:
readlink does not append a null byte to the output string!
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127
--- LVM2/libdm/libdm-common.c 2011/09/22 17:23:36 1.126
+++ LVM2/libdm/libdm-common.c 2011/09/24 11:47:53 1.127
@@ -1145,6 +1145,7 @@
log_sys_error("readlink", sysfs_path);
return 0;
}
+ temp_path[size] = '\0';
if (!(kernel_dev_name = strrchr(temp_path, '/'))) {
log_error("Could not locate device kernel name in sysfs path %s", temp_path);
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2011-07-08 15:34 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2011-07-08 15:34 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-07-08 15:34:47
Modified files:
libdm : libdm-common.c
Log message:
Log cookie values when incrementing/decrementing to give clues about races.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.123&r2=1.124
--- LVM2/libdm/libdm-common.c 2011/07/05 16:17:14 1.123
+++ LVM2/libdm/libdm-common.c 2011/07/08 15:34:47 1.124
@@ -1240,6 +1240,7 @@
static int _udev_notify_sem_inc(uint32_t cookie, int semid)
{
struct sembuf sb = {0, 1, 0};
+ int val;
if (semop(semid, &sb, 1) < 0) {
log_error("semid %d: semop failed for cookie 0x%" PRIx32 ": %s",
@@ -1247,8 +1248,15 @@
return 0;
}
- log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented",
- cookie, semid);
+ if ((val = semctl(semid, 0, GETVAL)) < 0) {
+ log_error("semid %d: sem_ctl GETVAL failed for "
+ "cookie 0x%" PRIx32 ": %s",
+ semid, cookie, strerror(errno));
+ return 0;
+ }
+
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented to %d",
+ cookie, semid, val);
return 1;
}
@@ -1256,6 +1264,14 @@
static int _udev_notify_sem_dec(uint32_t cookie, int semid)
{
struct sembuf sb = {0, -1, IPC_NOWAIT};
+ int val;
+
+ if ((val = semctl(semid, 0, GETVAL)) < 0) {
+ log_error("semid %d: sem_ctl GETVAL failed for "
+ "cookie 0x%" PRIx32 ": %s",
+ semid, cookie, strerror(errno));
+ return 0;
+ }
if (semop(semid, &sb, 1) < 0) {
switch (errno) {
@@ -1274,8 +1290,8 @@
return 0;
}
- log_debug("Udev cookie 0x%" PRIx32 " (semid %d) decremented",
- cookie, semid);
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) decremented to %d",
+ cookie, semid, val - 1);
return 1;
}
@@ -1299,6 +1315,7 @@
{
int fd;
int gen_semid;
+ int val;
uint16_t base_cookie;
uint32_t gen_cookie;
union semun sem_arg;
@@ -1359,8 +1376,15 @@
goto bad;
}
- log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented",
- gen_cookie, gen_semid);
+ if ((val = semctl(gen_semid, 0, GETVAL)) < 0) {
+ log_error("semid %d: sem_ctl GETVAL failed for "
+ "cookie 0x%" PRIx32 ": %s",
+ gen_semid, gen_cookie, strerror(errno));
+ return 0;
+ }
+
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented to %d",
+ gen_cookie, gen_semid, val);
if (close(fd))
stack;
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2011-07-05 16:17 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2011-07-05 16:17 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-07-05 16:17:14
Modified files:
libdm : libdm-common.c
Log message:
decode cookie flags in debug msgs
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123
--- LVM2/libdm/libdm-common.c 2011/07/01 14:09:20 1.122
+++ LVM2/libdm/libdm-common.c 2011/07/05 16:17:14 1.123
@@ -1391,6 +1391,51 @@
return _udev_notify_sem_create(cookie, &semid);
}
+static const char *_task_type_disp(int type)
+{
+ switch(type) {
+ case DM_DEVICE_CREATE:
+ return "CREATE";
+ case DM_DEVICE_RELOAD:
+ return "RELOAD";
+ case DM_DEVICE_REMOVE:
+ return "REMOVE";
+ case DM_DEVICE_REMOVE_ALL:
+ return "REMOVE_ALL";
+ case DM_DEVICE_SUSPEND:
+ return "SUSPEND";
+ case DM_DEVICE_RESUME:
+ return "RESUME";
+ case DM_DEVICE_INFO:
+ return "INFO";
+ case DM_DEVICE_DEPS:
+ return "DEPS";
+ case DM_DEVICE_RENAME:
+ return "RENAME";
+ case DM_DEVICE_VERSION:
+ return "VERSION";
+ case DM_DEVICE_STATUS:
+ return "STATUS";
+ case DM_DEVICE_TABLE:
+ return "TABLE";
+ case DM_DEVICE_WAITEVENT:
+ return "WAITEVENT";
+ case DM_DEVICE_LIST:
+ return "LIST";
+ case DM_DEVICE_CLEAR:
+ return "CLEAR";
+ case DM_DEVICE_MKNODES:
+ return "MKNODES";
+ case DM_DEVICE_LIST_VERSIONS:
+ return "LIST_VERSIONS";
+ case DM_DEVICE_TARGET_MSG:
+ return "TARGET_MSG";
+ case DM_DEVICE_SET_GEOMETRY:
+ return "SET_GEOMETRY";
+ }
+ return "unknown";
+}
+
int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags)
{
int semid;
@@ -1419,8 +1464,16 @@
dmt->event_nr |= ~DM_UDEV_FLAGS_MASK & *cookie;
dmt->cookie_set = 1;
- log_debug("Udev cookie 0x%" PRIx32 " (semid %d) assigned to dm_task "
- "type %d with flags 0x%" PRIx16, *cookie, semid, dmt->type, flags);
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) assigned to "
+ "%s task(%d) with flags%s%s%s%s%s%s%s (0x%" PRIx16 ")", *cookie, semid, _task_type_disp(dmt->type), dmt->type,
+ (flags & DM_UDEV_DISABLE_DM_RULES_FLAG) ? " DISABLE_DM_RULES" : "",
+ (flags & DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG) ? " DISABLE_SUBSYSTEM_RULES" : "",
+ (flags & DM_UDEV_DISABLE_DISK_RULES_FLAG) ? " DISABLE_DISK_RULES" : "",
+ (flags & DM_UDEV_DISABLE_OTHER_RULES_FLAG) ? " DISABLE_OTHER_RULES" : "",
+ (flags & DM_UDEV_LOW_PRIORITY_FLAG) ? " LOW_PRIORITY" : "",
+ (flags & DM_UDEV_DISABLE_LIBRARY_FALLBACK) ? " DISABLE_LIBRARY_FALLBACK" : "",
+ (flags & DM_UDEV_PRIMARY_SOURCE_FLAG) ? " PRIMARY_SOURCE" : "",
+ flags);
return 1;
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2011-06-28 9:24 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2011-06-28 9:24 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-06-28 09:24:14
Modified files:
libdm : libdm-common.c
Log message:
more fixes to readahead etc.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121
--- LVM2/libdm/libdm-common.c 2011/06/27 22:38:53 1.120
+++ LVM2/libdm/libdm-common.c 2011/06/28 09:24:13 1.121
@@ -864,13 +864,6 @@
char *pos;
/*
- * Clear warn_if_udev_failed if rely_on_udev is set. It doesn't get
- * checked in this case - this just removes the flag from log messages.
- */
- if (rely_on_udev)
- warn_if_udev_failed = 0;
-
- /*
* Note: warn_if_udev_failed must have valid content
*/
if ((type == NODE_DEL) && _other_node_ops(type))
@@ -911,10 +904,16 @@
*/
dm_list_iterate_safe(noph, nopht, &_node_ops) {
nop = dm_list_item(noph, struct node_op_parms);
- if (!strcmp(old_name, nop->dev_name))
+ if (!strcmp(old_name, nop->dev_name)) {
_log_node_op("Unstacking", nop);
_del_node_op(nop);
+ }
}
+ else if (type == NODE_READ_AHEAD) {
+ /* udev doesn't process readahead */
+ rely_on_udev = 0;
+ warn_if_udev_failed = 0;
+ }
if (!(nop = dm_malloc(sizeof(*nop) + len))) {
log_error("Insufficient memory to stack mknod operation");
@@ -930,9 +929,14 @@
nop->mode = mode;
nop->read_ahead = read_ahead;
nop->read_ahead_flags = read_ahead_flags;
- nop->warn_if_udev_failed = warn_if_udev_failed;
nop->rely_on_udev = rely_on_udev;
+ /*
+ * Clear warn_if_udev_failed if rely_on_udev is set. It doesn't get
+ * checked in this case - this just removes the flag from log messages.
+ */
+ nop->warn_if_udev_failed = rely_on_udev ? 0 : warn_if_udev_failed;
+
_store_str(&pos, &nop->dev_name, dev_name);
_store_str(&pos, &nop->old_name, old_name);
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2011-03-02 8:40 zkabelac
0 siblings, 0 replies; 21+ messages in thread
From: zkabelac @ 2011-03-02 8:40 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-03-02 08:40:28
Modified files:
libdm : libdm-common.c
Log message:
Add missing return
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112
--- LVM2/libdm/libdm-common.c 2011/03/02 00:29:57 1.111
+++ LVM2/libdm/libdm-common.c 2011/03/02 08:40:28 1.112
@@ -1427,6 +1427,8 @@
int r = _udev_wait(cookie);
update_devs();
+
+ return r;
}
#endif /* UDEV_SYNC_SUPPORT */
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2010-12-13 12:44 prajnoha
0 siblings, 0 replies; 21+ messages in thread
From: prajnoha @ 2010-12-13 12:44 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2010-12-13 12:44:10
Modified files:
libdm : libdm-common.c
Log message:
HAVE_SELINUX again
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106
--- LVM2/libdm/libdm-common.c 2010/12/13 12:30:04 1.105
+++ LVM2/libdm/libdm-common.c 2010/12/13 12:44:09 1.106
@@ -387,10 +387,10 @@
return 1;
}
+#ifdef HAVE_SELINUX
static int _selabel_lookup(const char *path, mode_t mode,
security_context_t *scontext)
{
-#ifdef HAVE_SELINUX
#ifdef HAVE_SELINUX_LABEL_H
if (!_selabel_handle &&
!(_selabel_handle = selabel_open(SELABEL_CTX_FILE, NULL, 0))) {
@@ -408,9 +408,9 @@
return 0;
}
#endif
-#endif
return 1;
}
+#endif
int dm_prepare_selinux_context(const char *path, mode_t mode)
{
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2010-12-13 12:30 prajnoha
0 siblings, 0 replies; 21+ messages in thread
From: prajnoha @ 2010-12-13 12:30 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2010-12-13 12:30:05
Modified files:
libdm : libdm-common.c
Log message:
#ifdef HAVE_SELINUX and #ifdef HAVE_SELINUX_LABEL_H
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105
--- LVM2/libdm/libdm-common.c 2010/12/13 12:18:38 1.104
+++ LVM2/libdm/libdm-common.c 2010/12/13 12:30:04 1.105
@@ -390,6 +390,7 @@
static int _selabel_lookup(const char *path, mode_t mode,
security_context_t *scontext)
{
+#ifdef HAVE_SELINUX
#ifdef HAVE_SELINUX_LABEL_H
if (!_selabel_handle &&
!(_selabel_handle = selabel_open(SELABEL_CTX_FILE, NULL, 0))) {
@@ -401,12 +402,13 @@
log_error("selabel_lookup failed: %s", strerror(errno));
return 0;
}
-#elif HAVE_SELINUX
+#else
if (matchpathcon(path, mode, scontext)) {
log_error("matchpathcon failed: %s", strerror(errno));
return 0;
}
#endif
+#endif
return 1;
}
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2010-12-13 12:18 prajnoha
0 siblings, 0 replies; 21+ messages in thread
From: prajnoha @ 2010-12-13 12:18 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2010-12-13 12:18:38
Modified files:
libdm : libdm-common.c
Log message:
Missing #elif HAVE_SELINUX
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104
--- LVM2/libdm/libdm-common.c 2010/12/13 10:43:58 1.103
+++ LVM2/libdm/libdm-common.c 2010/12/13 12:18:38 1.104
@@ -401,7 +401,7 @@
log_error("selabel_lookup failed: %s", strerror(errno));
return 0;
}
-#else
+#elif HAVE_SELINUX
if (matchpathcon(path, mode, scontext)) {
log_error("matchpathcon failed: %s", strerror(errno));
return 0;
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2010-11-29 10:11 zkabelac
0 siblings, 0 replies; 21+ messages in thread
From: zkabelac @ 2010-11-29 10:11 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2010-11-29 10:11:51
Modified files:
libdm : libdm-common.c
Log message:
Cleanup remove test for NULL
dm_free is testing NULL itself
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.101&r2=1.102
--- LVM2/libdm/libdm-common.c 2010/10/15 01:10:28 1.101
+++ LVM2/libdm/libdm-common.c 2010/11/29 10:11:50 1.102
@@ -250,10 +250,8 @@
char path[PATH_MAX];
struct stat st1, st2;
- if (dmt->dev_name) {
- dm_free(dmt->dev_name);
- dmt->dev_name = NULL;
- }
+ dm_free(dmt->dev_name);
+ dmt->dev_name = NULL;
/*
* Path supplied for existing device?
@@ -292,8 +290,7 @@
if (strlen(name) >= DM_NAME_LEN) {
log_error("Name \"%s\" too long", name);
- if (new_name)
- dm_free(new_name);
+ dm_free(new_name);
return 0;
}
@@ -309,10 +306,7 @@
int dm_task_set_uuid(struct dm_task *dmt, const char *uuid)
{
- if (dmt->uuid) {
- dm_free(dmt->uuid);
- dmt->uuid = NULL;
- }
+ dm_free(dmt->uuid);
if (!(dmt->uuid = dm_strdup(uuid))) {
log_error("dm_task_set_uuid: strdup(%s) failed", uuid);
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-09-25 19:06 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2009-09-25 19:06 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2009-09-25 19:06:05
Modified files:
libdm : libdm-common.c
Log message:
missing dm_snprintf
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85
--- LVM2/libdm/libdm-common.c 2009/09/25 18:19:09 1.84
+++ LVM2/libdm/libdm-common.c 2009/09/25 19:06:05 1.85
@@ -261,7 +261,11 @@
* under /dev/mapper, use that name directly. Otherwise call
* _find_dm_name_of_device() to scan _dm_dir for a match.
*/
- snprintf(path, sizeof(path), "%s/%s", _dm_dir, pos + 1);
+ if (dm_snprintf(path, sizeof(path), "%s/%s", _dm_dir,
+ pos + 1) == -1) {
+ log_error("Couldn't create path for %s", pos + 1);
+ return 0;
+ }
if (!stat(path, &st2) && (st1.st_rdev == st2.st_rdev))
name = pos + 1;
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-09-25 18:13 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2009-09-25 18:13 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2009-09-25 18:13:17
Modified files:
libdm : libdm-common.c
Log message:
remove unused var & rename fn
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83
--- LVM2/libdm/libdm-common.c 2009/09/25 18:08:04 1.82
+++ LVM2/libdm/libdm-common.c 2009/09/25 18:13:17 1.83
@@ -187,7 +187,7 @@
/*
* Find the name associated with a given device number by scanning _dm_dir.
*/
-static char *_translate_name(dev_t st_rdev, const char *devname)
+static char *_find_dm_name_of_device(dev_t st_rdev)
{
const char *name;
char path[PATH_MAX];
@@ -257,13 +257,13 @@
/*
* If supplied path points to same device as last component
* under /dev/mapper, use that name directly. Otherwise call
- * _translate_name() to scan _dm_dir for a match.
+ * _find_dm_name_of_device() to scan _dm_dir for a match.
*/
snprintf(path, sizeof(path), "%s/%s", _dm_dir, pos + 1);
if (!stat(path, &st2) && (st1.st_rdev == st2.st_rdev))
name = pos + 1;
- else if ((new_name = _translate_name(st1.st_rdev, pos + 1)))
+ else if ((new_name = _find_dm_name_of_device(st1.st_rdev)))
name = new_name;
else {
log_error("Device %s not found", name);
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-09-11 16:11 prajnoha
0 siblings, 0 replies; 21+ messages in thread
From: prajnoha @ 2009-09-11 16:11 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2009-09-11 16:11:25
Modified files:
libdm : libdm-common.c
Log message:
Move dm_cookie_supported check into dm_udev_get_sync_supprt function.
We don't have to call dm_cookie_supported with dm_udev_get_sync_support
this way. Also, it's necessary for the current code to work properly on
systems without cookie support (older kernels).
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80
--- LVM2/libdm/libdm-common.c 2009/09/11 15:57:51 1.79
+++ LVM2/libdm/libdm-common.c 2009/09/11 16:11:25 1.80
@@ -881,7 +881,7 @@
if (_udev_running < 0)
_udev_running = _check_udev_is_running();
- return _udev_running && _sync_with_udev;
+ return dm_cookie_supported() && _udev_running && _sync_with_udev;
}
static int _get_cookie_sem(uint32_t cookie, int *semid)
@@ -1064,7 +1064,7 @@
{
int semid;
- if (!dm_udev_get_sync_support() || !dm_cookie_supported()) {
+ if (!dm_udev_get_sync_support()) {
dmt->event_nr = *cookie = 0;
return 1;
}
@@ -1099,7 +1099,7 @@
{
int semid;
- if (!cookie || !dm_udev_get_sync_support() || !dm_cookie_supported())
+ if (!cookie || !dm_udev_get_sync_support())
return 1;
if (!_get_cookie_sem(cookie, &semid))
@@ -1120,7 +1120,7 @@
int semid;
struct sembuf sb = {0, 0, 0};
- if (!cookie || !dm_udev_get_sync_support() || !dm_cookie_supported())
+ if (!cookie || !dm_udev_get_sync_support())
return 1;
if (!_get_cookie_sem(cookie, &semid))
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-09-11 15:57 prajnoha
0 siblings, 0 replies; 21+ messages in thread
From: prajnoha @ 2009-09-11 15:57 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2009-09-11 15:57:51
Modified files:
libdm : libdm-common.c
Log message:
Add one define that is necessary for older (experimental) libudev to work.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79
--- LVM2/libdm/libdm-common.c 2009/09/11 15:56:07 1.78
+++ LVM2/libdm/libdm-common.c 2009/09/11 15:57:51 1.79
@@ -29,6 +29,7 @@
# include <sys/ipc.h>
# include <sys/sem.h>
#ifdef HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE
+# define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
# include <libudev.h>
#endif
#endif
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-08-06 15:00 prajnoha
0 siblings, 0 replies; 21+ messages in thread
From: prajnoha @ 2009-08-06 15:00 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2009-08-06 15:00:25
Modified files:
libdm : libdm-common.c
Log message:
Detect udev problems in _rename_dev_node.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
--- LVM2/libdm/libdm-common.c 2009/08/05 19:50:08 1.74
+++ LVM2/libdm/libdm-common.c 2009/08/06 15:00:25 1.75
@@ -381,6 +381,29 @@
return 1;
}
+static int _rm_dev_node(const char *dev_name)
+{
+ char path[PATH_MAX];
+ struct stat info;
+
+ _build_dev_path(path, sizeof(path), dev_name);
+
+ if (stat(path, &info) < 0)
+ return 1;
+ else if (dm_udev_get_sync_support())
+ log_warn("Node %s was not removed by udev. "
+ "Falling back to direct node removal.", path);
+
+ if (unlink(path) < 0) {
+ log_error("Unable to unlink device node for '%s'", dev_name);
+ return 0;
+ }
+
+ log_debug("Removed %s", path);
+
+ return 1;
+}
+
static int _rename_dev_node(const char *old_name, const char *new_name)
{
char oldpath[PATH_MAX];
@@ -396,6 +419,19 @@
"is already present", newpath);
return 0;
}
+ else if (dm_udev_get_sync_support()) {
+ if (stat(oldpath, &info) < 0 &&
+ errno == ENOENT)
+ /* assume udev already deleted this */
+ return 1;
+ else {
+ log_warn("The node %s should have been renamed to %s "
+ "by udev but old node is still present. "
+ "Falling back to direct old node removal.",
+ oldpath, newpath);
+ return _rm_dev_node(old_name);
+ }
+ }
if (unlink(newpath) < 0) {
if (errno == EPERM) {
@@ -407,6 +443,11 @@
return 0;
}
}
+ else if (dm_udev_get_sync_support())
+ log_warn("The node %s should have been renamed to %s "
+ "by udev but new node is not present. "
+ "Falling back to direct node rename.",
+ oldpath, newpath);
if (rename(oldpath, newpath) < 0) {
log_error("Unable to rename device node from '%s' to '%s'",
@@ -419,29 +460,6 @@
return 1;
}
-static int _rm_dev_node(const char *dev_name)
-{
- char path[PATH_MAX];
- struct stat info;
-
- _build_dev_path(path, sizeof(path), dev_name);
-
- if (stat(path, &info) < 0)
- return 1;
- else if (dm_udev_get_sync_support())
- log_warn("Node %s was not removed by udev. "
- "Falling back to direct node removal.", path);
-
- if (unlink(path) < 0) {
- log_error("Unable to unlink device node for '%s'", dev_name);
- return 0;
- }
-
- log_debug("Removed %s", path);
-
- return 1;
-}
-
#ifdef linux
static int _open_dev_node(const char *dev_name)
{
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-08-05 19:50 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2009-08-05 19:50 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2009-08-05 19:50:08
Modified files:
libdm : libdm-common.c
Log message:
Additional logging
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74
--- LVM2/libdm/libdm-common.c 2009/08/03 18:33:08 1.73
+++ LVM2/libdm/libdm-common.c 2009/08/05 19:50:08 1.74
@@ -854,41 +854,50 @@
return 0;
}
-static int _udev_notify_sem_inc(int semid)
+static int _udev_notify_sem_inc(uint32_t cookie, int semid)
{
struct sembuf sb = {0, 1, 0};
if (semop(semid, &sb, 1) < 0) {
- log_error("semid %d: semop failed: %s", semid, strerror(errno));
+ log_error("semid %d: semop failed for cookie 0x%" PRIx32 ": %s",
+ semid, cookie, strerror(errno));
return 0;
}
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented",
+ cookie, semid);
+
return 1;
}
-static int _udev_notify_sem_dec(int semid)
+static int _udev_notify_sem_dec(uint32_t cookie, int semid)
{
struct sembuf sb = {0, -1, IPC_NOWAIT};
if (semop(semid, &sb, 1) < 0) {
switch (errno) {
case EAGAIN:
- log_error("semid %d: semop failed: "
+ log_error("semid %d: semop failed for cookie "
+ "0x%" PRIx32 ": "
"incorrect semaphore state",
- semid);
+ semid, cookie);
break;
default:
- log_error("semid %d: semop failed: %s",
- semid, strerror(errno));
+ log_error("semid %d: semop failed for cookie "
+ "0x%" PRIx32 ": %s",
+ semid, cookie, strerror(errno));
break;
}
return 0;
}
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) decremented",
+ cookie, semid);
+
return 1;
}
-static int _udev_notify_sem_destroy(int semid, uint32_t cookie)
+static int _udev_notify_sem_destroy(uint32_t cookie, int semid)
{
if (semctl(semid, 0, IPC_RMID, 0) < 0) {
log_error("Could not cleanup notification semaphore "
@@ -897,6 +906,9 @@
return 0;
}
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) destroyed", cookie,
+ semid);
+
return 1;
}
@@ -950,14 +962,20 @@
}
} while (!base_cookie);
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) created",
+ gen_cookie, gen_semid);
+
if (semctl(gen_semid, 0, SETVAL, 1) < 0) {
log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno));
/* We have to destroy just created semaphore
* so it won't stay in the system. */
- (void) _udev_notify_sem_destroy(gen_semid, gen_cookie);
+ (void) _udev_notify_sem_destroy(gen_cookie, gen_semid);
goto bad;
}
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented",
+ gen_cookie, gen_semid);
+
if (close(fd))
stack;
@@ -990,7 +1008,7 @@
} else if (!_udev_notify_sem_create(cookie, &semid))
goto_bad;
- if (!_udev_notify_sem_inc(semid)) {
+ if (!_udev_notify_sem_inc(*cookie, semid)) {
log_error("Could not set notification semaphore "
"identified by cookie value %" PRIu32 " (0x%x)",
*cookie, *cookie);
@@ -999,6 +1017,10 @@
dmt->event_nr = *cookie;
dmt->cookie_set = 1;
+
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) assigned to dm_task",
+ dmt->event_nr, semid);
+
return 1;
bad:
@@ -1016,7 +1038,7 @@
if (!_get_cookie_sem(cookie, &semid))
return_0;
- if (!_udev_notify_sem_dec(semid)) {
+ if (!_udev_notify_sem_dec(cookie, semid)) {
log_error("Could not signal waiting process using notification "
"semaphore identified by cookie value %" PRIu32 " (0x%x)",
cookie, cookie);
@@ -1037,15 +1059,18 @@
if (!_get_cookie_sem(cookie, &semid))
return_0;
- if (!_udev_notify_sem_dec(semid)) {
+ if (!_udev_notify_sem_dec(cookie, semid)) {
log_error("Failed to set a proper state for notification "
"semaphore identified by cookie value %" PRIu32 " (0x%x) "
"to initialize waiting for incoming notifications.",
cookie, cookie);
- (void) _udev_notify_sem_destroy(semid, cookie);
+ (void) _udev_notify_sem_destroy(cookie, semid);
return 0;
}
+ log_debug("Udev cookie 0x%" PRIx32 " (semid %d): Waiting for zero",
+ cookie, semid);
+
repeat_wait:
if (semop(semid, &sb, 1) < 0) {
if (errno == EINTR)
@@ -1053,11 +1078,11 @@
log_error("Could not set wait state for notification semaphore "
"identified by cookie value %" PRIu32 " (0x%x): %s",
cookie, cookie, strerror(errno));
- (void) _udev_notify_sem_destroy(semid, cookie);
+ (void) _udev_notify_sem_destroy(cookie, semid);
return 0;
}
- return _udev_notify_sem_destroy(semid, cookie);
+ return _udev_notify_sem_destroy(cookie, semid);
}
#endif /* UDEV_SYNC_SUPPORT */
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-08-03 18:33 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2009-08-03 18:33 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2009-08-03 18:33:08
Modified files:
libdm : libdm-common.c
Log message:
Add udev checks.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
--- LVM2/libdm/libdm-common.c 2009/08/03 18:01:47 1.72
+++ LVM2/libdm/libdm-common.c 2009/08/03 18:33:08 1.73
@@ -355,7 +355,9 @@
dev_name);
return 0;
}
- }
+ } else if (dm_udev_get_sync_support())
+ log_warn("%s not set up by udev: Falling back to direct "
+ "node creation.", path);
old_mask = umask(0);
if (mknod(path, S_IFBLK | mode, dev) < 0) {
@@ -426,6 +428,9 @@
if (stat(path, &info) < 0)
return 1;
+ else if (dm_udev_get_sync_support())
+ log_warn("Node %s was not removed by udev. "
+ "Falling back to direct node removal.", path);
if (unlink(path) < 0) {
log_error("Unable to unlink device node for '%s'", dev_name);
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-08-03 11:01 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2009-08-03 11:01 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2009-08-03 11:01:26
Modified files:
libdm : libdm-common.c
Log message:
deal with error-related FIXMEs
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70
--- LVM2/libdm/libdm-common.c 2009/07/31 17:51:46 1.69
+++ LVM2/libdm/libdm-common.c 2009/08/03 11:01:26 1.70
@@ -818,7 +818,13 @@
static int _get_cookie_sem(uint32_t cookie, int *semid)
{
- /* FIXME Ensure cookie has COOKIE_MAGIC prefix */
+ if (!(cookie >> 16 & COOKIE_MAGIC)) {
+ log_error("Could not continue to access notification "
+ "semaphore identified by cookie value %"
+ PRIu32 " (0x%x). Incorrect cookie prefix.");
+ return 0;
+ }
+
if ((*semid = semget((key_t) cookie, 1, 0)) >= 0)
return 1;
@@ -836,11 +842,10 @@
cookie, cookie);
break;
default:
- /* FIXME errno use missing */
log_error("Failed to access notification "
"semaphore identified by cookie "
- "value %" PRIu32 " (0x%x)",
- cookie, cookie);
+ "value %" PRIu32 " (0x%x): %s",
+ cookie, cookie, strerror(errno));
break;
}
@@ -851,26 +856,42 @@
{
struct sembuf sb = {0, 1, 0};
- /* FIXME errno use missing */
- return semop(semid, &sb, 1) == 0;
+ if (semop(semid, &sb, 1) < 0) {
+ log_error("semid %d: semop failed: %s", semid, strerror(errno));
+ return 0;
+ }
+
+ return 1;
}
static int _udev_notify_sem_dec(int semid)
{
- /* FIXME Think we should have IPC_NOWAIT here in case something went wrong and it's already 0 */
- struct sembuf sb = {0, -1, 0};
+ struct sembuf sb = {0, -1, IPC_NOWAIT};
+
+ if (semop(semid, &sb, 1) < 0) {
+ switch (errno) {
+ case EAGAIN:
+ log_error("semid %d: semop failed: "
+ "incorrect semaphore state",
+ semid);
+ break;
+ default:
+ log_error("semid %d: semop failed: %s",
+ semid, strerror(errno));
+ break;
+ }
+ return 0;
+ }
- /* FIXME errno use missing */
- return semop(semid, &sb, 1) == 0;
+ return 1;
}
static int _udev_notify_sem_destroy(int semid, uint32_t cookie)
{
- /* FIXME errno use missing */
if (semctl(semid, 0, IPC_RMID, 0) < 0) {
log_error("Could not cleanup notification semaphore "
- "identified by cookie value %" PRIu32 " (0x%x)",
- cookie, cookie);
+ "identified by cookie value %" PRIu32 " (0x%x): %s",
+ cookie, cookie, strerror(errno));
return 0;
}
@@ -914,22 +935,21 @@
"notification semaphore");
goto bad;
case ENOSPC:
- /* FIXME Suggest what to check & do */
log_error("Limit for the maximum number "
- "of semaphores reached");
+ "of semaphores reached. You can "
+ "check and set the limits in "
+ "/proc/sys/kernel/sem.");
goto bad;
default:
- /* FIXME Use errno */
- log_error("Failed to create "
- "notification semaphore");
+ log_error("Failed to create notification "
+ "semaphore: %s", strerror(errno));
goto bad;
}
}
} while (!base_cookie);
if (semctl(gen_semid, 0, SETVAL, 1) < 0) {
- /* FIXME Use errno and give gen_semid */
- log_error("Failed to initialize notification semaphore");
+ log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno));
/* We have to destroy just created semaphore
* so it won't stay in the system. */
_udev_notify_sem_destroy(gen_semid, gen_cookie);
@@ -1027,10 +1047,9 @@
if (semop(semid, &sb, 1) < 0) {
if (errno == EINTR)
goto repeat_wait;
- /* FIXME missing errno use */
log_error("Could not set wait state for notification semaphore "
- "identified by cookie value %" PRIu32 " (0x%x)",
- cookie, cookie);
+ "identified by cookie value %" PRIu32 " (0x%x): %s",
+ cookie, cookie, strerror(errno));
_udev_notify_sem_destroy(semid, cookie);
return 0;
}
^ permalink raw reply [flat|nested] 21+ messages in thread
* LVM2/libdm libdm-common.c
@ 2009-07-31 16:57 agk
0 siblings, 0 replies; 21+ messages in thread
From: agk @ 2009-07-31 16:57 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2009-07-31 16:57:08
Modified files:
libdm : libdm-common.c
Log message:
another fixme
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68
--- LVM2/libdm/libdm-common.c 2009/07/31 15:53:12 1.67
+++ LVM2/libdm/libdm-common.c 2009/07/31 16:57:06 1.68
@@ -818,6 +818,7 @@
static int _get_cookie_sem(uint32_t cookie, int *semid)
{
+ /* FIXME Ensure cookie has COOKIE_MAGIC prefix */
if ((*semid = semget((key_t) cookie, 1, 0)) >= 0)
return 1;
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2012-02-13 14:39 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-25 18:19 LVM2/libdm libdm-common.c agk
-- strict thread matches above, loose matches on Subject: below --
2012-02-13 14:39 zkabelac
2012-01-25 21:47 zkabelac
2011-09-24 11:47 prajnoha
2011-07-08 15:34 agk
2011-07-05 16:17 agk
2011-06-28 9:24 agk
2011-03-02 8:40 zkabelac
2010-12-13 12:44 prajnoha
2010-12-13 12:30 prajnoha
2010-12-13 12:18 prajnoha
2010-11-29 10:11 zkabelac
2009-09-25 19:06 agk
2009-09-25 18:13 agk
2009-09-11 16:11 prajnoha
2009-09-11 15:57 prajnoha
2009-08-06 15:00 prajnoha
2009-08-05 19:50 agk
2009-08-03 18:33 agk
2009-08-03 11:01 agk
2009-07-31 16:57 agk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).