Abhishekmishra2808 commented on code in PR #19165:
URL: https://github.com/apache/nuttx/pull/19165#discussion_r3446750418
##########
fs/tmpfs/fs_tmpfs.c:
##########
@@ -1936,6 +2139,36 @@ static int tmpfs_fstat(FAR const struct file *filep, FAR
struct stat *buf)
return OK;
}
+/****************************************************************************
+ * Name: tmpfs_fchstat
+ ****************************************************************************/
+
+static int tmpfs_fchstat(FAR const struct file *filep,
+ FAR const struct stat *buf, int flags)
+{
+ DEBUGASSERT(filep->f_priv != NULL && buf != NULL);
+
+#ifndef CONFIG_FS_PERMISSION
Review Comment:
Done
##########
fs/tmpfs/fs_tmpfs.c:
##########
@@ -555,12 +561,176 @@ static int tmpfs_add_dirent(FAR struct tmpfs_directory_s
*tdo,
return OK;
}
+#if defined(CONFIG_FS_PERMISSION)
+
+/****************************************************************************
+ * Name: tmpfs_init_object
+ ****************************************************************************/
+
+static void tmpfs_init_object(FAR struct tmpfs_object_s *to, mode_t mode)
+{
+ FAR struct tcb_s *rtcb;
+
+ to->to_mode = mode & 07777;
+ rtcb = nxsched_self();
+ if ((rtcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL ||
+ rtcb->group == NULL)
+ {
+ to->to_uid = 0;
+ to->to_gid = 0;
+ }
+ else
+ {
+ to->to_uid = rtcb->group->tg_euid;
+ to->to_gid = rtcb->group->tg_egid;
+ }
+}
+
+/****************************************************************************
+ * Name: tmpfs_check_pathperm
+ ****************************************************************************/
+
+static int tmpfs_check_pathperm(FAR struct tmpfs_s *fs,
+ FAR const char *relpath, size_t relpathlen,
+ int final_amode)
+{
+ FAR struct tmpfs_directory_s *tdo;
+ FAR struct tmpfs_object_s *to;
+ size_t begin = 0;
+ size_t end;
+ int ret;
+
+ while (begin < relpathlen && relpath[begin] == '/')
+ {
+ begin++;
+ }
+
+ if (begin >= relpathlen)
+ {
+ to = fs->tfs_root.tde_object;
+ return fs_checkmode(to->to_uid, to->to_gid,
+ to->to_mode | S_IFDIR, final_amode);
+ }
+
+ end = begin;
+ while (end <= relpathlen)
+ {
+ if (end < relpathlen && relpath[end] != '/')
+ {
+ end++;
+ continue;
+ }
+
+ if (end == begin)
+ {
+ break;
+ }
+
+ ret = tmpfs_find_directory(fs, relpath, end, &tdo, NULL);
+ if (ret < 0)
+ {
+ return ret;
+ }
+
+ to = (FAR struct tmpfs_object_s *)tdo;
+ ret = fs_checkmode(to->to_uid, to->to_gid,
+ to->to_mode | S_IFDIR,
+ (end >= relpathlen) ? final_amode : X_OK);
Review Comment:
Done
##########
fs/tmpfs/fs_tmpfs.c:
##########
@@ -555,12 +561,176 @@ static int tmpfs_add_dirent(FAR struct tmpfs_directory_s
*tdo,
return OK;
}
+#if defined(CONFIG_FS_PERMISSION)
+
+/****************************************************************************
+ * Name: tmpfs_init_object
+ ****************************************************************************/
+
+static void tmpfs_init_object(FAR struct tmpfs_object_s *to, mode_t mode)
+{
+ FAR struct tcb_s *rtcb;
+
+ to->to_mode = mode & 07777;
+ rtcb = nxsched_self();
+ if ((rtcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL ||
+ rtcb->group == NULL)
+ {
+ to->to_uid = 0;
+ to->to_gid = 0;
+ }
+ else
+ {
+ to->to_uid = rtcb->group->tg_euid;
+ to->to_gid = rtcb->group->tg_egid;
+ }
+}
+
+/****************************************************************************
+ * Name: tmpfs_check_pathperm
+ ****************************************************************************/
+
+static int tmpfs_check_pathperm(FAR struct tmpfs_s *fs,
+ FAR const char *relpath, size_t relpathlen,
+ int final_amode)
+{
+ FAR struct tmpfs_directory_s *tdo;
+ FAR struct tmpfs_object_s *to;
+ size_t begin = 0;
+ size_t end;
+ int ret;
+
+ while (begin < relpathlen && relpath[begin] == '/')
+ {
+ begin++;
+ }
+
+ if (begin >= relpathlen)
+ {
+ to = fs->tfs_root.tde_object;
+ return fs_checkmode(to->to_uid, to->to_gid,
+ to->to_mode | S_IFDIR, final_amode);
+ }
+
+ end = begin;
+ while (end <= relpathlen)
+ {
+ if (end < relpathlen && relpath[end] != '/')
+ {
+ end++;
+ continue;
+ }
+
+ if (end == begin)
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]