fstat(): Rethink procfs fstat(). If write method is supported, then should report file s writeable.

This commit is contained in:
Gregory Nutt 2017-02-15 09:32:42 -06:00
parent 1474300276
commit bae367c7c4
3 changed files with 29 additions and 13 deletions

13
TODO
View File

@ -1293,8 +1293,8 @@ o Libraries (libc/, libm/)
Priority: ??
Title: FLOATING POINT FORMATS
Description: Only the %f floating point format is supported. Others are accepted
but treated like %f.
Description: Only the %f floating point format is supported. Others are
accepted but treated like %f.
Status: Open
Priority: Medium (this might important to someone).
@ -1346,7 +1346,7 @@ o Libraries (libc/, libm/)
Priority: Low for casual users but clearly high if you need care about
these incorrect corner case behaviors in the math libraries.
Title: Repartition libc functionality.
Title: REPARTITION LIBC FUNCTIONALITY
Description: There are many things implemented within the kernel (for example
under sched/pthread) that probably should be migrated in the
C library where it belongs.
@ -1877,9 +1877,10 @@ o Network Utilities (apps/netutils/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Title: UNVERIFIED THTTPD FEATURES
Description: Not all THTTPD features/options have been verified. In particular, there is no
test case of a CGI program receiving POST input. Only the configuration of
apps/examples/thttpd has been tested.
Description: Not all THTTPD features/options have been verified. In
particular, there is no test case of a CGI program receiving
POST input. Only the configuration of apps/examples/thttpd
has been tested.
Status: Open
Priority: Medium

View File

@ -250,7 +250,6 @@ static int _inode_search(FAR struct inode_search_s *desc)
DEBUGASSERT(desc != NULL && desc->path != NULL);
name = desc->path;
DEBUGASSERT(*name == '/');
if (*name != '/')
{
return -EINVAL;

View File

@ -474,16 +474,32 @@ static int procfs_dup(FAR const struct file *oldp, FAR struct file *newp)
static int procfs_fstat(FAR const struct file *filep, FAR struct stat *buf)
{
/* This is trivially simple in the current implementation. The procfs
* file system contains only directory and read-only data file entries.
* Therefore, the return buf always has the same fixed values.
*
* REVISIT: This, of course, will need to change if read-write procfs
* entries are to be supported.
FAR struct procfs_file_s *handler;
finfo("buf=%p\n", buf);
/* Recover our private data from the struct file instance */
handler = (FAR struct procfs_file_s *)filep->f_priv;
DEBUGASSERT(handler);
/* The procfs file system contains only directory and data file entries.
* Since the file has been opened, we know that this is a data file and,
* at a minimum, readable.
*/
memset(buf, 0, sizeof(struct stat));
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
/* If the write method is provided, then let's also claim that the file is
* writable.
*/
if (handler->procfsentry->ops->write != NULL)
{
buf->st_mode |= S_IWOTH | S_IWGRP | S_IWUSR;
}
return OK;
}