lib: posix: fs: add ftruncate support
Add support for ftruncate in posix implementation Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
This commit is contained in:
parent
feae0a229b
commit
cd1ed1cdbf
|
@ -238,6 +238,7 @@ ssize_t write(int file, const void *buffer, size_t count);
|
|||
ssize_t read(int file, void *buffer, size_t count);
|
||||
off_t lseek(int file, off_t offset, int whence);
|
||||
int fsync(int fd);
|
||||
int ftruncate(int fd, off_t length);
|
||||
|
||||
/* File System related operations */
|
||||
int rename(const char *old, const char *newp);
|
||||
|
|
|
@ -416,3 +416,18 @@ int mkdir(const char *path, mode_t mode)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Truncate file to specified length.
|
||||
*
|
||||
*/
|
||||
int ftruncate(int fd, off_t length)
|
||||
{
|
||||
struct posix_fs_desc *ptr = NULL;
|
||||
|
||||
ptr = z_get_fd_obj(fd, NULL, EBADF);
|
||||
if (!ptr)
|
||||
return -1;
|
||||
|
||||
return fs_truncate(&ptr->file, length);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue