You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xiaoxiang781216 (via GitHub)" <gi...@apache.org> on 2023/08/12 10:20:42 UTC

[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10203: builtin: support uid/gid config for binfs app

xiaoxiang781216 commented on code in PR #10203:
URL: https://github.com/apache/nuttx/pull/10203#discussion_r1292201964


##########
fs/binfs/fs_binfs.c:
##########
@@ -469,21 +469,35 @@ static int binfs_stat(struct inode *mountpt,
                       const char *relpath, struct stat *buf)
 {
   finfo("Entry\n");
+  int index;
+#ifdef CONFIG_SCHED_USER_IDENTITY
+  int mode;
+#endif
 
   /* The requested directory must be the volume-relative "root" directory */
 
   if (relpath && relpath[0] != '\0')
     {
       /* Check if there is a file with this name. */
 
-      if (builtin_isavail(relpath) < 0)
+      index = builtin_isavail(relpath);
+      if (index < 0)
         {
           return -ENOENT;
         }
 
       /* It's a execute-only file name */
 
       buf->st_mode = S_IFREG | S_IXOTH | S_IXGRP | S_IXUSR;
+
+#ifdef CONFIG_SCHED_USER_IDENTITY
+      buf->st_uid = builtin_getuid(index);
+      buf->st_gid = builtin_getgid(index);
+
+      mode = builtin_getmode(index);
+      buf->st_mode |= (mode & S_ISUID) ? S_ISUID : 0;

Review Comment:
   ```suggestion
         buf->st_mode = builtin_getmode(index);
   ```
   and remove mode variable



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org