mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/6] fs: implement fstat
Date: Wed,  8 Oct 2014 16:24:13 +0200	[thread overview]
Message-ID: <1412778255-4153-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1412778255-4153-1-git-send-email-s.hauer@pengutronix.de>

fstat is useful to get information about an already opened file. Add
it to barebox.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/fs.c      | 16 ++++++++++++++++
 include/fs.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index 436f5cb..ffdfa2c 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1472,6 +1472,22 @@ out:
 }
 EXPORT_SYMBOL(lstat);
 
+int fstat(int fd, struct stat *s)
+{
+	FILE *f;
+	struct fs_device_d *fsdev;
+
+	if (check_fd(fd))
+		return -errno;
+
+	f = &files[fd];
+
+	fsdev = f->fsdev;
+
+	return fsdev->driver->stat(&fsdev->dev, f->path, s);
+}
+EXPORT_SYMBOL(fstat);
+
 int mkdir (const char *pathname, mode_t mode)
 {
 	struct fs_driver_d *fsdrv;
diff --git a/include/fs.h b/include/fs.h
index 6eddb23..63e35ca 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -114,6 +114,7 @@ int close(int fd);
 int flush(int fd);
 int lstat(const char *filename, struct stat *s);
 int stat(const char *filename, struct stat *s);
+int fstat(int fd, struct stat *s);
 ssize_t read(int fd, void *buf, size_t count);
 ssize_t pread(int fd, void *buf, size_t count, loff_t offset);
 int ioctl(int fd, int request, void *buf);
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-10-08 14:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08 14:24 [PATCH 1/6] fs: store pointer to fsdev instead of dev in struct filep Sascha Hauer
2014-10-08 14:24 ` [PATCH 2/6] fs: do not lookup global FILE * when the file is already available Sascha Hauer
2014-10-08 14:24 ` [PATCH 3/6] fs: Store the path in struct filep Sascha Hauer
2014-10-08 14:24 ` Sascha Hauer [this message]
2014-10-08 14:24 ` [PATCH 5/6] libfile: add diff_file function Sascha Hauer
2014-10-08 14:24 ` [PATCH 6/6] commands: implement 'diff' command Sascha Hauer
2014-10-08 15:32   ` Antony Pavlov
2014-10-09  6:50     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1412778255-4153-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox