AliOS Things API VFS Guide - Shaofa/AliOS-Things-Certification-Manual GitHub Wiki

API INDEX


1-aos_open

int aos_open(const char *path, int flags)
  • Description

    Open the file or device by its path.

  • Parameters

    IN/OUT NAME DESC
    [in] path the path of the file or device to open.
    [in] flags the mode of open operation.
  • Returns

    the new file descriptor, negative error on failure.

2-aos_close

int aos_close(int fd)
  • Description

    Close the file or device by its file descriptor.

  • Parameters

    IN/OUT NAME DESC
    [in] fd the file descriptor of the file or device.
  • Returns

    0 on success, negative error on failure.

3-aos_read

ssize_t aos_read(int fd, void *buf, size_t nbytes)
  • Description

    Read the contents of a file or device into a buffer.

  • Parameters

    IN/OUT NAME DESC
    [in] fd the file descriptor of the file or device.
    [in] nbytes the number of bytes to read.
    [out] buf the buffer to read in to.
  • Returns

    The number of bytes read, 0 at end of file, negative error on failure.

4-aos_write

ssize_t aos_write(int fd, const void *buf, size_t nbytes)
  • Description

    Write the contents of a buffer to file or device.

  • Parameters

    IN/OUT NAME DESC
    [in] fd the file descriptor of the file or device.
    [in] nbytes the number of bytes to write.
    [in] buf the buffer to write from.
  • Returns

    The number of bytes written, negative error on failure.

5-aos_ioctl

int aos_ioctl(int fd, int cmd, unsigned long arg)
  • Description

    This is a wildcard API for sending controller specific commands.

  • Parameters

    IN/OUT NAME DESC
    [in] fd the file descriptior of the file or device.
    [in] cmd A controller specific command.
    [in] arg Argument to the command, interpreted according to the command.
  • Returns

    any return from the command.

6-aos_poll

int aos_poll(struct pollfd *fds, int nfds, int timeout)
  • Description

    A mechanism to multiplex input/output over a set of file descriptors. For every file descriptor provided, poll() examines it for any events registered for that particular file descriptor.

  • Parameters

    IN/OUT NAME DESC
    [in] fds a point to the array of pollfd struct carrying a file descriptor and bitmasks of events.
    [in] nfhs number of file descriptors.
    [in] timeout timer value to timeout or -1 for loop forever.
  • Returns

    number of file descriptors selected (for which revents is non-zero). 0 if timed out with nothing selected. -1 for error.

7-aos_fcntl

int aos_fcntl(int fd, int cmd, int val)
  • Description

    Performs one of the operations described below on the open file descriptor, The operation is determined by cmd.

  • Parameters

    IN/OUT NAME DESC
    [in] fd the file descriptor of the file or device.
    [in] cmd the operation of the file or device.
    [in] val it depends on whether cmd need params.
  • Returns

    0 on success, negative error on failure.

8-aos_lseek

off_t aos_lseek(int fd, off_t offset, int whence)
  • Description

    Move the file position to a given offset from a given location.

  • Parameters

    IN/OUT NAME DESC
    [in] fd the file descriptor of the file.
    [in] offset The offset from whence to move to.
    [in] whence The start of where to seek.SEEK_SET to start from beginning of file.SEEK_CUR to start from current position in file.SEEK_END to start from end of file.
  • Returns

    The new offset of the file.

9-aos_sync

int aos_sync(int fd)
  • Description

    Flush any buffers associated with the file.

  • Parameters

    IN/OUT NAME DESC
    [in] fd the file descriptor of the file.
  • Returns

    0 on success, negative error code on failure.

10-aos_stat

int aos_stat(const char *path, struct stat *st)
  • Description

    Store information about the file in a stat structure.

  • Parameters

    IN/OUT NAME DESC
    [in] path The path of the file to find information about.
    [out] st The stat buffer to write to.
  • Returns

    0 on success, negative error code on failure.

11-aos_unlink

int aos_unlink(const char *path)
  • Description

    Remove a file from the filesystem.

  • Parameters

    IN/OUT NAME DESC
    [in] path The path of the file to remove.
  • Returns

    0 on success, negative error code on failure.

12-aos_rename

int aos_rename(const char *oldpath, const char *newpath)
  • Description

    Rename a file in the filesystem.

  • Parameters

    IN/OUT NAME DESC
    [in] oldpath The path of the file to rename.
    [in] newpath The path to rename it to.
  • Returns

    0 on success, negative error code on failure.

13-aos_opendir

aos_dir_t *aos_opendir(const char *path)
  • Description

    Open a directory on the filesystem.

  • Parameters

    IN/OUT NAME DESC
    [in] path the path of the directory to open.
  • Returns

    a point of directory stream on success, NULL on failure.

14-aos_closedir

int aos_closedir(aos_dir_t *dir)
  • Description

    Close a directory.

  • Parameters

    IN/OUT NAME DESC
    [in] dir the handle of the directory to close.
  • Returns

    0 on success, negative error code on failure.

15-aos_readdir

aos_dirent_t *aos_readdir(aos_dir_t *dir)
  • Description

    Read the next directory entry.

  • Parameters

    IN/OUT NAME DESC
    [in] dir the handle of the directory to read.
  • Returns

    a pointer to a dirent structure.

16-aos_mkdir

int aos_mkdir(const char *path)
  • Description

    Create the directory, if they do not already exist.

  • Parameters

    IN/OUT NAME DESC
    [in] path the path of the directory.
  • Returns

    0 on success, negative error code on failure.

⚠️ **GitHub.com Fallback** ⚠️