Polished messages, comments and description of DDLP-A
This commit is contained in:
parent
9cfe22531d
commit
65f82d82ab
@ -148,6 +148,44 @@ With hdc, of course, things are trivial
|
|||||||
ddlpa: opened /dev/hdc
|
ddlpa: opened /dev/hdc
|
||||||
slept 1 seconds of 1
|
slept 1 seconds of 1
|
||||||
|
|
||||||
|
|
||||||
|
Ted Ts'o provided program open-cd-excl which allows to explore open(2) on
|
||||||
|
device files with combinations of read-write, O_EXCL, and fcntl().
|
||||||
|
(This does not mean that Ted endorsed our project yet. He helps exploring.)
|
||||||
|
|
||||||
|
Friendly in the sense of DDLP-A would be any run which uses at least one of
|
||||||
|
the options -e (i.e. O_EXCL) or -f (i.e. F_SETLK).
|
||||||
|
The code is available under GPL at
|
||||||
|
http://libburnia.pykix.org/browser/libburn/trunk/test/open-cd-excl.c?format=txt
|
||||||
|
To be compiled by
|
||||||
|
cc -g -Wall -o open-cd-excl open-cd-excl.c
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-e : open O_EXCL
|
||||||
|
-f : aquire lock by fcntl(F_SETLK) after sucessful open
|
||||||
|
-i : do not wait in case of success but exit 0 immediately
|
||||||
|
-r : open O_RDONLY , with -f use F_RDLCK
|
||||||
|
-w : open O_RDWR , with -f use F_WRLCK
|
||||||
|
plus the path of the devce file to open.
|
||||||
|
|
||||||
|
Friendly Programs would use gestures like:
|
||||||
|
./open-cd-excl -e -r /dev/sr0
|
||||||
|
./open-cd-excl -e -w /dev/sg1
|
||||||
|
./open-cd-excl -e -w /dev/black-drive
|
||||||
|
./open-cd-excl -f -r /dev/sg1
|
||||||
|
./open-cd-excl -e -f -w /dev/sr0
|
||||||
|
|
||||||
|
Ignorant programs would use:
|
||||||
|
./open-cd-excl -r /dev/sr0
|
||||||
|
./open-cd-excl -w /dev/sg1
|
||||||
|
./open-cd-excl -f -w /dev/black-drive
|
||||||
|
where "/dev/black-drive" is _not_ a symbolic link to
|
||||||
|
any of /dev/sr* /dev/scd* /dev/sg*, but has an own inode.
|
||||||
|
|
||||||
|
Prone to failure without further reason is:
|
||||||
|
./open-cd-excl -e -r /dev/sg1
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
|
|
||||||
DDLP-B
|
DDLP-B
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE \
|
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE \
|
||||||
-DDDLPA_C_STANDALONE -o ddlpa ddlpa.c
|
-DDDLPA_C_STANDALONE -o ddlpa ddlpa.c
|
||||||
|
|
||||||
The system macros are needed for 8-bit off_t and for open flag O_LARGEFILE
|
The system macros enable 64-bit off_t and open(2) flag O_LARGEFILE, which
|
||||||
which are not absolutely necessary but explicitely take into respect that
|
are not absolutely necessary but explicitely take into respect that
|
||||||
our devices can offer more than 2 GB of addressable data.
|
our devices can offer more than 2 GB of addressable data.
|
||||||
|
|
||||||
Run test program:
|
Run test program:
|
||||||
@ -42,6 +42,12 @@
|
|||||||
static int ddlpa_debug_mode = 1;
|
static int ddlpa_debug_mode = 1;
|
||||||
|
|
||||||
|
|
||||||
|
/* #define _GNU_SOURCE or _LARGEFILE64_SOURCE to get real O_LARGEFILE */
|
||||||
|
#ifndef O_LARGEFILE
|
||||||
|
#define O_LARGEFILE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------- private -------------------- */
|
/* ----------------------- private -------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
progname = argv[0];
|
progname = argv[0];
|
||||||
|
|
||||||
/* ts A70417: added -w and -r */
|
/* ts A70417: added -w , -r , -i */
|
||||||
while ((c = getopt (argc, argv, "feirw")) != EOF) {
|
while ((c = getopt (argc, argv, "feirw")) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'e':
|
case 'e':
|
||||||
@ -119,6 +119,7 @@ int main(int argc, char **argv)
|
|||||||
printf("Trying to grab fcntl lock...\n");
|
printf("Trying to grab fcntl lock...\n");
|
||||||
if (fcntl(fd, F_SETLKW, &fl) < 0) {
|
if (fcntl(fd, F_SETLKW, &fl) < 0) {
|
||||||
perror("fcntl: F_SETLKW: ");
|
perror("fcntl: F_SETLKW: ");
|
||||||
|
printf("failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("succeeded\n");
|
printf("succeeded\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user