diff --git a/libgphoto2_port/ChangeLog b/libgphoto2_port/ChangeLog index 9a770aa9f..643e60555 100644 --- a/libgphoto2_port/ChangeLog +++ b/libgphoto2_port/ChangeLog @@ -1,3 +1,7 @@ +2001-10-03 Lutz Müller + + * serial/unix.c: Correctly interpret the return value of dev_[un]lock + 2001-10-03 Lutz Müller * test/gphoto2-port-test.c: Renamed into diff --git a/libgphoto2_port/serial/unix.c b/libgphoto2_port/serial/unix.c index 10576f1bc..c51cd54cc 100644 --- a/libgphoto2_port/serial/unix.c +++ b/libgphoto2_port/serial/unix.c @@ -143,8 +143,15 @@ gp_port_serial_lock (gp_port *dev, const char *port) if (!pid) return (GP_OK); - gp_port_debug_printf (GP_DEBUG_LOW, dev->debug_level, "Device '%s' is " - "locked by pid %d.", port, pid); + /* Tell the user what went wrong */ + if (pid > 0) + gp_port_debug_printf (GP_DEBUG_LOW, dev->debug_level, "Device " + "'%s' is locked by pid %d.", port, pid); + else + gp_port_debug_printf (GP_DEBUG_LOW, dev->debug_level, + "dev_lock on '%s' returned %d.", + port, pid); + return (GP_ERROR_IO_LOCK); #else /* !HAVE_LOCKDEV */ @@ -291,8 +298,15 @@ gp_port_serial_unlock (gp_port *dev) if (!pid) return (GP_OK); - gp_port_debug_printf (GP_DEBUG_LOW, dev->debug_level, "Device '%s' is " - "locked by pid %d.", port, pid); + /* Tell the user what went wrong */ + if (pid > 0) + gp_port_debug_printf (GP_DEBUG_LOW, dev->debug_level, "Device " + "'%s' is locked by pid %d.", port, pid); + else + gp_port_debug_printf (GP_DEBUG_LOW, dev->debug_level, + "dev_unlock on '%s' returned %d.", + port, pid); + return (GP_ERROR_IO_LOCK); #else /* !HAVE_LOCKDEV */