ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am working on a Linux device driver, and have already implimented the basic open(), read(), write() and close() function. The next thing I need to add is a flush() operation, as there are several things that need to be reinitialised between tasks. I think I know what to do on the kernel side of things, but I actually do not know what the flush command is! There does not seem to be an actual `int flush(int fd)' function (at least, there is no man page for it on my system), so I guess the function is named something else.
Simple question, really: what is the C function that falls the flush() operation from a device driver?
here is an excerpt from the gnu c programming tutorial for fflush im sure flush is similar tho.
Quote:
Having stdin and stdout be line-buffered is convenient, because most meaningful chunks of data you write to them are terminated with a newline character. In order to ensure that the data you read from or write to a fully-buffered stream shows up right away, use the fflush function. In the jargon, this is called flushing the stream. Flushing moves the characters from the buffer to the file, if they haven't already been moved. After the move, other functions can then work on the characters.1
To use fflush, simply pass the function the stream you want to flush. The fflush function returns 0 if successful, or the value EOF (which is a macro defined in the GNU C Library) if there was a write error.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.