This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bad file descriptor with fctnl


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]