procfs: Most stat() implementations were not initializating the st_atime, st_ctime, and st_mtime fields.

This commit is contained in:
Gregory Nutt 2017-02-15 09:59:09 -06:00
parent bae367c7c4
commit c67943ed1d
5 changed files with 17 additions and 28 deletions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* fs/procfs/fs_procfscpuload.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -333,10 +333,8 @@ static int cpuload_stat(const char *relpath, struct stat *buf)
/* "cpuload" is the name for a read-only file */
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
buf->st_size = 0;
buf->st_blksize = 0;
buf->st_blocks = 0;
memset(buf, 0, sizeof(struct stat));
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
return OK;
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* fs/procfs/fs_procfskmm.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -312,10 +312,8 @@ static int kmm_stat(FAR const char *relpath, FAR struct stat *buf)
/* "kmm" is the name for a read-only file */
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
buf->st_size = 0;
buf->st_blksize = 0;
buf->st_blocks = 0;
memset(buf, 0, sizeof(struct stat));
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
return OK;
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* fs/procfs/fs_procfsproc.c
*
* Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -1552,6 +1552,7 @@ static int proc_stat(const char *relpath, struct stat *buf)
/* Was the <pid> the final element of the path? */
memset(buf, 0, sizeof(struct stat));
if (*ptr == '\0' || strcmp(ptr, "/") == 0)
{
/* Yes ... It's a read-only directory */
@ -1601,11 +1602,6 @@ static int proc_stat(const char *relpath, struct stat *buf)
}
}
/* File/directory size, access block size */
buf->st_size = 0;
buf->st_blksize = 0;
buf->st_blocks = 0;
return OK;
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* fs/procfs/fs_procfsuptime.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -346,10 +346,8 @@ static int uptime_stat(FAR const char *relpath, FAR struct stat *buf)
/* "uptime" is the name for a read-only file */
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
buf->st_size = 0;
buf->st_blksize = 0;
buf->st_blocks = 0;
memset(buf, 0, sizeof(struct stat));
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
return OK;
}

View File

@ -1,6 +1,7 @@
/****************************************************************************
* fs/procfs/fs_skeleton.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Ken Pettit. All rights reserved.
* Author: Ken Pettit <pettitkd@gmail.com>
*
@ -438,7 +439,7 @@ static int skel_rewinddir(FAR struct fs_dirent_s *dir)
*
****************************************************************************/
static int skel_stat(FAR const char *relpath, FAR truct stat *buf)
static int skel_stat(FAR const char *relpath, FAR struct stat *buf)
{
int ret = -ENOENT;
@ -446,15 +447,13 @@ static int skel_stat(FAR const char *relpath, FAR truct stat *buf)
* or a directory and set it's permissions.
*/
memset(buf, 0, sizeof(struct stat));
buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR;
/* Other 'struct buf' settings may be appropriate (optional) */
ret = OK;
/* File/directory size, access block size */
buf->st_size = 0;
buf->st_blksize = 0;
buf->st_blocks = 0;
return ret;
}