Questions tagged [fcntl]

fcntl refers to a function that provides control over the open file referenced by a file descriptor

fcntl refers to a function that provides control over the open file referenced by a file descriptor.

234 questions
0
votes
1 answer

Proper format of fstore for fcntl under Python

I want to preallocate storage for files using python. With fcntl, I can preallocate storage under C: int fd = myFileHandle; fstore_t store = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, aLength}; int ret = fcntl(fd, F_PREALLOCATE, &store); if(-1…
blackirishman
  • 903
  • 1
  • 10
  • 23
0
votes
0 answers

What is the practical use of F_DUPFD in fcntl function

int fcntl(int fd,F_DUPFD,.../int arg/). The fcntl function in unix programming uses F_DUPFD file descriptor flag.The f_DUPFD clears the FD_CLOEXEC file descriptor for the next lowest available file descriptor. This new file descriptor has the same…
Shanif Ansari
  • 239
  • 2
  • 9
0
votes
1 answer

Non Blocking Socket Blocked by fgets

I'm testing things out and i made a non blocking socket but the "fgets" ruined my plans. How can i prevent fgets for blocking out my while loop showing below? A code that solves this would be greatly appreciated. fcntl(clientSocket, F_SETFL,…
0
votes
0 answers

Checking whether unlocking file was successful - fcntl

While writing a code to train some unix locks I have come across a problem. So my question is - how to properly check if unlocking has finished successfully? I looked at the example in manual and did this: struct flock* createLock(int descr, int…
Kanes115
  • 119
  • 6
0
votes
1 answer

FCNTL returns errno - Invalid argument

I can't figure out why my fcntl keeps saying "Invalid argument". Please, help. If I understand it correctly I should fill my flock (the one that I pass to fcntl) with data that points to a byte I want to check. int byteno; …
Kanes115
  • 119
  • 6
0
votes
2 answers

How to store a word using read()?

About the program: Hello, I am writing a simple program to extract content from a .txt file and convert that content into a .csv file. The plan is to look for specific words within that .txt file. This is really just to experiment with the functions…
Jose Ortiz
  • 311
  • 1
  • 3
  • 14
0
votes
1 answer

Ignoring comment lines marked with "%" using open() in C on linux

I am trying to read a file which has the first two lines marked with a "%" as the first character. I need to ignore these two lines, and then read 4 separate integer variables, separated by an unknown amount of white space. This then repeats for…
0
votes
1 answer

fcntl bytes file locking in linux

I have lock on particular bytes in file using fcntl with some values of fl.1_start and f1.1_len. while program is running, i tried to write into that file from other program on those bytes. when both programs running simultaneously, second program…
Nazeem
  • 59
  • 11
0
votes
0 answers

How to randomnly lock some bytes in file using fcntl()?

I am trying to study fnctl record locking. I created two files file1.c and file2.c. Both files write a string to "data" file. I created a lock using fnctl for whole file. when I run both programs from two terminals (cc file1.c -o file1) (cc file2.c…
Nazeem
  • 59
  • 11
0
votes
1 answer

linux fcntl+F_NOTIFY not working as expected: when there's change, nothing triggered

I'm on RHEL5 with kernel 2.6.32. Trying to see if fcntl+F_NOTIFY could work to monitor a directory or file change. I searched google and found this file: #define _GNU_SOURCE #include #include #include #include…
Troskyvs
  • 7,537
  • 7
  • 47
  • 115
0
votes
2 answers

GAE python asyncore issue

I was trying to use pyDNS on GAE. In Base.py there is import asyncore Thats what I get: File "/base/data/home/apps/myapp/lib/DNS/Base.py", line 14, in import asyncore File…
IvBaranov
  • 540
  • 2
  • 10
  • 24
0
votes
0 answers

trying to read from stdout with NONBLOCKING set using winARM newlib lpc

I want read on stdout to be non-blocking. I was using the newlib-lpc library in WINarm to do this. But even though it is set as non-Blocking, the code stops at read every time and waits for a character to be received. Here is my read…
ej_01
  • 51
  • 4
0
votes
2 answers

stat.h file access file descriptors open() Hacking The Art of Exploitation

I am working out of the 2nd edition of Jon Erickson's "Hacking: The Art of Exploitation" using a VM (virutalbox) to run the LiveCD it came with (Ubuntu 7.04). In section 0x281 "File Access", the author explains accessing files through file…
user1234
  • 21
  • 4
0
votes
2 answers

"Invalid argument" on the use of fcntl in C

I have been trying to understand the reason and cannot find a valid reason for Invalid Argument error given on the use of perror. Can anyone suggest the reason for this error? #include #include #include #include…
0
votes
0 answers

userspace file locking library

I need to port sqlite to an embeded non-posix OS. Problem is that OS doesn't support posix file locking mechanism. Is there any userspace posix lock library implementation that I may use?
incogn1to
  • 429
  • 4
  • 17