diff --git a/doc/ddlp.txt b/doc/ddlp.txt index c200af6..69763a5 100644 --- a/doc/ddlp.txt +++ b/doc/ddlp.txt @@ -148,6 +148,44 @@ With hdc, of course, things are trivial ddlpa: opened /dev/hdc 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 diff --git a/libburn/ddlpa.c b/libburn/ddlpa.c index 2dfebbe..b58e021 100644 --- a/libburn/ddlpa.c +++ b/libburn/ddlpa.c @@ -11,8 +11,8 @@ -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE \ -DDDLPA_C_STANDALONE -o ddlpa ddlpa.c - The system macros are needed for 8-bit off_t and for open flag O_LARGEFILE - which are not absolutely necessary but explicitely take into respect that + The system macros enable 64-bit off_t and open(2) flag O_LARGEFILE, which + are not absolutely necessary but explicitely take into respect that our devices can offer more than 2 GB of addressable data. Run test program: @@ -42,6 +42,12 @@ 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 -------------------- */ diff --git a/test/open-cd-excl.c b/test/open-cd-excl.c index 34404e2..80efae0 100644 --- a/test/open-cd-excl.c +++ b/test/open-cd-excl.c @@ -52,7 +52,7 @@ int main(int argc, char **argv) progname = argv[0]; - /* ts A70417: added -w and -r */ + /* ts A70417: added -w , -r , -i */ while ((c = getopt (argc, argv, "feirw")) != EOF) { switch (c) { case 'e': @@ -119,6 +119,7 @@ int main(int argc, char **argv) printf("Trying to grab fcntl lock...\n"); if (fcntl(fd, F_SETLKW, &fl) < 0) { perror("fcntl: F_SETLKW: "); + printf("failed\n"); exit(1); } printf("succeeded\n");