Author: aschnell
Date: Sun Aug 3 23:42:15 2008
New Revision: 49611
URL: http://svn.opensuse.org/viewcvs/yast?rev=49611&view=rev
Log:
- finished locking support
Modified:
trunk/storage/libstorage/src/Lock.cc
trunk/storage/libstorage/src/StorageInterface.h
trunk/storage/libstorage/testsuite/lib/limal_init.exp
trunk/storage/yast2-storage.spec.in
Modified: trunk/storage/libstorage/src/Lock.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Lock.cc?rev=49611&r1=49610&r2=49611&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Lock.cc (original)
+++ trunk/storage/libstorage/src/Lock.cc Sun Aug 3 23:42:15 2008
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#include "y2storage/AppUtil.h"
#include "y2storage/Lock.h"
@@ -31,16 +32,19 @@
Lock::Lock(bool readonly)
: fd(-1)
{
+ if (getenv("YAST2_STORAGE_NO_LOCKING") != NULL)
+ return;
+
y2mil("getting " << (readonly ? "read-only" : "read-write") << " lock");
- if (mkdir("/var/lock/libstorage", 0622) < 0)
+ if (mkdir("/var/lock/libstorage", 0755) < 0)
{
- // Creating directory failed. Not fatal (should already exist).
+ // Creating directory failed. Not fatal (it should already exist).
y2deb("creating directory for lock-file failed: " << strerror(errno));
}
fd = open("/var/lock/libstorage/lock", (readonly ? O_RDONLY : O_WRONLY) | O_CREAT,
- S_IRUSR | S_IWUSR);
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0)
{
// Opening lock-file failed.
@@ -79,11 +83,14 @@
Lock::~Lock() throw()
{
+ if (getenv("YAST2_STORAGE_NO_LOCKING") != NULL)
+ return;
+
y2mil("releasing lock");
close(fd);
- // Do not bother deleting lock-file. This is difficult if there are
- // several read-only locks.
+ // Do not bother deleting lock-file. Likelihood of race conditions is
+ // to high.
}
}
Modified: trunk/storage/libstorage/src/StorageInterface.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageInterface.h?rev=49611&r1=49610&r2=49611&view=diff
==============================================================================
--- trunk/storage/libstorage/src/StorageInterface.h (original)
+++ trunk/storage/libstorage/src/StorageInterface.h Sun Aug 3 23:42:15 2008
@@ -56,6 +56,8 @@
*
* The support for multiple read-only locks is experimental.
*
+ * Locking may also fail for other reasons, e.g. limited permissions.
+ *
* \section Example
*
* Here is a simple example to demonstrate the usage of libstorage:
Modified: trunk/storage/libstorage/testsuite/lib/limal_init.exp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/lib/limal_init.exp?rev=49611&r1=49610&r2=49611&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite/lib/limal_init.exp (original)
+++ trunk/storage/libstorage/testsuite/lib/limal_init.exp Sun Aug 3 23:42:15 2008
@@ -30,7 +30,7 @@
puts "Running $base_name..."
- #generate output directory
+ # generate output directory
exec mkdir -p ./single.out/out
set outfile ./single.out/out/$base_name.out
@@ -40,6 +40,8 @@
# run the test
+ setenv YAST2_STORAGE_NO_LOCKING
+
set result ""
set oops [catch { set result [exec $src >$outfile 2>$errfile] } catched]
Modified: trunk/storage/yast2-storage.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/yast2-storage.spec.in?rev=49611&r1=49610&r2=49611&view=diff
==============================================================================
--- trunk/storage/yast2-storage.spec.in (original)
+++ trunk/storage/yast2-storage.spec.in Sun Aug 3 23:42:15 2008
@@ -33,6 +33,7 @@
@INSTALL@
rm -f $RPM_BUILD_ROOT/@plugindir@/libpy2StorageCallbacks.la
rm -f $RPM_BUILD_ROOT/@plugindir@/libpy2StorageCallbacks.so
+install -d -m 755 $RPM_BUILD_ROOT/var/lock/libstorage
@CLEAN@
@@ -93,6 +94,7 @@
%files lib
%defattr(-,root,root)
%{_libdir}/liby2storage.so.*
+%dir /var/lock/libstorage
%post lib
/sbin/ldconfig
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org