Example #1
0
int
fs_fgetattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi)
{
	struct inode *ino = (struct inode *)fi->fh;
	memset(stbuf, 0, sizeof(*stbuf));
	inode_stat(ino, stbuf);

	return 0;
}
Example #2
0
/**
 * Get metadata about file f.
 */
int
file_stat(struct file *f, struct file_stat *st)
{
  if(f->type == FD_INODE){
    inode_lock(f->ip);
    inode_stat(f->ip, st);
    inode_unlock(f->ip);
    return 0;
  }
  return -1;
}
Example #3
0
int
fs_getattr(const char *path, struct stat *stbuf)
{
	struct inode *ino;
	struct fuse_context *context;
	uint32_t i, nblocks, *pdiskbno;
	int r;

	if ((r = inode_open(path, &ino)) < 0)
		return r;
	memset(stbuf, 0, sizeof(*stbuf));
	inode_stat(ino, stbuf);

	return 0;
}
Example #4
0
int file_fstat(FAR struct file *filep, FAR struct stat *buf)
{
  FAR struct inode *inode;
  int ret;

  DEBUGASSERT(filep != NULL);

  /* Get the inode from the file structure */

  inode = filep->f_inode;
  DEBUGASSERT(inode != NULL);

  /* The way we handle the stat depends on the type of inode that we
   * are dealing with.
   */

#ifndef CONFIG_DISABLE_MOUNTPOINT
  if (INODE_IS_MOUNTPT(inode))
    {
      /* The inode is a file system mountpoint. Verify that the mountpoint
       * supports the fstat() method
       */

      ret = -ENOSYS;
      if (inode->u.i_mops && inode->u.i_mops->fstat)
        {
          /* Perform the fstat() operation */

          ret = inode->u.i_mops->fstat(filep, buf);
        }
    }
  else
#endif
    {
      /* The inode is part of the root pseudo file system. */

      ret = inode_stat(inode, buf);
    }

  return ret;
}
Example #5
0
int stat(FAR const char *path, FAR struct stat *buf)
{
	FAR struct inode *inode;
	const char *relpath = NULL;
	int ret = OK;

	/* Sanity checks */

	if (!path || !buf) {
		ret = EFAULT;
		goto errout;
	}

	if (!path[0]) {
		ret = ENOENT;
		goto errout;
	}

	/* Check for the fake root directory (which has no inode) */

	if (strcmp(path, "/") == 0) {
		return statroot(buf);
	}

	/* Get an inode for this file */

	inode = inode_find(path, &relpath);
	if (!inode) {
		/* This name does not refer to a psudeo-inode and there is no
		 * mountpoint that includes in this path.
		 */

		ret = ENOENT;
		goto errout;
	}

	/* The way we handle the stat depends on the type of inode that we
	 * are dealing with.
	 */

#ifndef CONFIG_DISABLE_MOUNTPOINT
	if (INODE_IS_MOUNTPT(inode)) {
		/* The node is a file system mointpoint. Verify that the mountpoint
		 * supports the stat() method
		 */

		if (inode->u.i_mops && inode->u.i_mops->stat) {
			/* Perform the stat() operation */

			ret = inode->u.i_mops->stat(inode, relpath, buf);
		}
	} else
#endif
	{
		/* The node is part of the root pseudo file system */

		ret = inode_stat(inode, buf);
	}

	/* Check if the stat operation was successful */

	if (ret < 0) {
		ret = -ret;
		goto errout_with_inode;
	}

	/* Successfully stat'ed the file */

	inode_release(inode);
	return OK;

	/* Failure conditions always set the errno appropriately */

errout_with_inode:
	inode_release(inode);
errout:
	set_errno(ret);
	return ERROR;
}