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
+7 -6
View File
@@ -1293,8 +1293,8 @@ o Libraries (libc/, libm/)
Priority: ?? Priority: ??
Title: FLOATING POINT FORMATS Title: FLOATING POINT FORMATS
Description: Only the %f floating point format is supported. Others are accepted Description: Only the %f floating point format is supported. Others are
but treated like %f. accepted but treated like %f.
Status: Open Status: Open
Priority: Medium (this might important to someone). 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 Priority: Low for casual users but clearly high if you need care about
these incorrect corner case behaviors in the math libraries. 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 Description: There are many things implemented within the kernel (for example
under sched/pthread) that probably should be migrated in the under sched/pthread) that probably should be migrated in the
C library where it belongs. C library where it belongs.
@@ -1877,9 +1877,10 @@ o Network Utilities (apps/netutils/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Title: UNVERIFIED THTTPD FEATURES Title: UNVERIFIED THTTPD FEATURES
Description: Not all THTTPD features/options have been verified. In particular, there is no Description: Not all THTTPD features/options have been verified. In
test case of a CGI program receiving POST input. Only the configuration of particular, there is no test case of a CGI program receiving
apps/examples/thttpd has been tested. POST input. Only the configuration of apps/examples/thttpd
has been tested.
Status: Open Status: Open
Priority: Medium Priority: Medium
-1
View File
@@ -250,7 +250,6 @@ static int _inode_search(FAR struct inode_search_s *desc)
DEBUGASSERT(desc != NULL && desc->path != NULL); DEBUGASSERT(desc != NULL && desc->path != NULL);
name = desc->path; name = desc->path;
DEBUGASSERT(*name == '/');
if (*name != '/') if (*name != '/')
{ {
return -EINVAL; return -EINVAL;
+22 -6
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) static int procfs_fstat(FAR const struct file *filep, FAR struct stat *buf)
{ {
/* This is trivially simple in the current implementation. The procfs FAR struct procfs_file_s *handler;
* file system contains only directory and read-only data file entries.
* Therefore, the return buf always has the same fixed values. finfo("buf=%p\n", buf);
*
* REVISIT: This, of course, will need to change if read-write procfs /* Recover our private data from the struct file instance */
* entries are to be supported.
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)); memset(buf, 0, sizeof(struct stat));
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; 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; return OK;
} }