This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Bad file descriptor with fctnl
- To: help-gcc at gnu dot org
- Subject: Bad file descriptor with fctnl
- From: swansonm at nospam dot iastate dot edu
- Date: Mon, 15 Nov 1999 09:27:35 -0600
- Newsgroups: gnu.gcc.help
- Xref: wodc7nx0 gnu.gcc.help:1829
Hi,
I'm trying to make a covert channel program (secure way of transfering information)
for a class.
Basicly, it signals bits through watching file locks.
I call open( ) on three different files.
if ((f_rdy = open("/tmp/.rdy", O_CREAT | O_WRONLY | O_TRUNC,
S_IRWXO | S_IRWXG | S_IRWXU)) < 0) {
perror(argv[0]);
exit(2);
}
and I get back the file descriptors 6, 8, 10.
Then I use fcntl to set or check on file locks. Yet I will get
the error message "bad file descriptor" on a few of the calls to fcntl()
lock.l_type = F_RDLCK; // set a write lock
lock.l_whence = 0; // start at beginning
lock.l_start = 0L;
lock.l_len = 0L; //whole file
if (fcntl(f_rdy, F_SETLK, &lock) < 0 )
perror("f_rdy set to rdlck by reader");
Does any one know what I"m doing wrong? Please directly email to
swansonm@nospam.iastate.edu by removing the "nospam." Thanks tons!
Michael