ETXTBSY error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi gurus,

I am all of a sudden getting ETXTBSY error executing a binary and reading some details on internet I found that reason could be:

This occurs when you try and write to a file that is currently being executed by the kernel, or execute a file that is currently open for writing.

I am trying to execute an ELF corresponding to the C program whose text is shown below. But above thing is not convincing - who can be writing to my file which is afterall a binary.

This binary sends some ioctl to a driver which has hooked read system call. please give me any pointers.

strace:
root@manoj-desktop:~/kdev/lockit/cmd/src# strace ./lock
execve("./lock", ["./lock"], [/* 37 vars */]) = -1 ETXTBSY (Text file busy)
dup(2)                                  = 3
fcntl64(3, F_GETFL)                     = 0x2 (flags O_RDWR)
fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fcd000
_llseek(3, 0, 0xbf817884, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
write(3, "strace: exec: Text file busy\n", 29strace: exec: Text file busy
) = 29
close(3)                                = 0
munmap(0xb7fcd000, 4096)                = 0
exit_group(1)                           = ?
Process 5119 detached
code:
...
       if(!strcmp(argv[1], "add")) {
                        filename = argv[2];
                        assert(filename != NULL);

                        rc = lstat(filename, &buf);
                        if(-1 == rc) {
                            printf("Failed while stating the file\n");
                            _exit(1);
                        }

                        msg->ino = buf.st_ino;

                        if(ioctl(fd, LOCKIT_MSG_ADD_FILE, msg) == -1) {
                            printf("ioctl to driver failed while adding file."
                                " errno [%d]\n", errno);
                            _exit(LOCKIT_ERR_DRV_IOCTL_FAILED);
                        }
                        printf("Successfully added %s to the Lockit DB\n",
                                argv[2]);
...

TIA,
-Manoj
--
What is important?  What you want to be true, or what is true?
---------------------------------------------------------------------------
http://awmanoj.blogspot.com

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux