Messages in this thread Patch in this message | | | From | (Matthias Urlichs) | Subject | Re: What is the intended function of open() system call? | Date | 13 Apr 1999 10:07:56 +0200 |
| |
Arvind Sankar <arvinds@mit.edu> writes: > > I think Leonov meant that the driver won't know inside open() whether it's > going to be read or written (since dd opens O_RDWR when it wants O_WRONLY), so > if different initialization is required for the two, you're screwed. > So you wait for the first read() or write() call to you driver if you get an open() with O_RDWR. You could also use additional heuristics, i.e.. an O_TRUNC flag certainly indicates that the program will want to write. ;-)
Dd uses O_RDWR because its skip() code falls back to read()ing the head of the file if it can't lseek() to the position you want. IMHO that's not necessary if you didn't give it any seek= option.
Patch to fileutils follows.
Index: src/dd.c --- noris.6/src/dd.c Sun, 14 Dec 1997 15:33:37 +0100 smurf (gnu_fileutils/21_dd.c 1.2 644) +++ noris.6(w)/src/dd.c Tue, 13 Apr 1999 10:05:49 +0200 smurf (gnu_fileutils/21_dd.c 1.2 644) @@ -364,7 +364,7 @@ if (output_file != NULL) { - int omode = O_RDWR | O_CREAT; + int omode = (seek_record ? O_RDWR : O_WRONLY) | O_CREAT; if (seek_record == 0 && !(conversions_mask & C_NOTRUNC)) omode |= O_TRUNC; -- Matthias Urlichs | noris network GmbH | smurf@noris.de | ICQ: 20193661 The quote was selected randomly. Really. | http://www.noris.de/~smurf/ -- If you think this is funny, look in a mirror. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |