Exemple #1
0
static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
  int ret;

  finfo("cmd: %d arg: %08lx\n", cmd, arg);

  /* Only one IOCTL command is supported */

  if (cmd == FIOC_FILENAME)
    {
      /* IN:  FAR char const ** pointer
       * OUT: Pointer to a persistent file name (Guaranteed to persist while
       *      the file is open).
       */

      FAR const char **ptr = (FAR const char **)((uintptr_t)arg);
      if (ptr == NULL)
        {
          ret = -EINVAL;
        }
      else
        {
          *ptr = builtin_getname((int)((uintptr_t)filep->f_priv));
          ret = OK;
        }
    }
  else
    {
      ret = -ENOTTY;
    }

  return ret;
}
Exemple #2
0
static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl)
{
#ifdef CONFIG_NSH_BUILTIN_APPS
  FAR const char *name;
  int i;

  /* List the set of available built-in commands */

  nsh_output(vtbl, "\nBuiltin Apps:\n");
  for (i = 0; (name = builtin_getname(i)) != NULL; i++)
    {
      nsh_output(vtbl, "  %s\n", name);
    }
#endif
}
Exemple #3
0
static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
{
  FAR const char *name;
  unsigned int index;
  int ret;

  /* Have we reached the end of the directory */

  index = dir->u.binfs.fb_index;
  name = builtin_getname(index);
  if (name == NULL)
    {
      /* We signal the end of the directory by returning the
       * special error -ENOENT
       */

      finfo("Entry %d: End of directory\n", index);
      ret = -ENOENT;
    }
  else
    {
      /* Save the filename and file type */

      finfo("Entry %d: \"%s\"\n", index, name);
      dir->fd_dir.d_type = DTYPE_FILE;
      strncpy(dir->fd_dir.d_name, name, NAME_MAX+1);

      /* The application list is terminated by an entry with a NULL name.
       * Therefore, there is at least one more entry in the list.
       */

      index++;

      /* Set up the next directory entry offset.  NOTE that we could use the
       * standard f_pos instead of our own private fb_index.
       */

      dir->u.binfs.fb_index = index;
      ret = OK;
    }

  return ret;
}