Write data to a file.
Include
None
Prototype
int __attribute__((__section__(".libc.write")))write(int
handle, void *buffer, unsigned int count);
Arguments
handle |
refers to an opened file |
buffer |
points to the storage location of data to be written |
count |
the number of characters to write. |
Return Value
If successful, write returns the number of characters actually written. A return value of ‘-1’ indicates an error.
Remarks
If the actual space remaining on the disk is less than the size of the buffer, the function trying to write to the disk write fails and does not flush any of the buffer’s contents to the disk. If the file is opened in text mode, each linefeed character is replaced with a carriage return – linefeed pair in the output. The replacement does not affect the return value.
This is a helper function called by the Standard C Library function
fflush()
.
Default Behavior
As distributed, the parameters are passed to the host file system through the simulator. The return value is the value returned by the host file system.
File
write.c