You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/07/14 15:40:54 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

xiaoxiang781216 opened a new pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153


   ## Summary
   and implement all status related change function. the individual
   file system change will provide in other upcoming patchset.
   
   ## Impact
   Support the new API(chmod, chown, utimes...)
   
   ## Testing
   
   


-- 
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



[GitHub] [incubator-nuttx] xiaoxiang781216 edited a comment on pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 edited a comment on pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153#issuecomment-888503541


   > CI fail due to libstdc++ call utimensat wrongly:
   > https://github.com/llvm/llvm-project/blob/main/libcxx/src/filesystem/filesystem_common.h#L30-L36
   > Let's wait @Donny9 ' xxxat patch to fix this issue first.
   
   Since utimensat need more time to support, I add a new patch to temporarily undefine UTIME_OMIT in C++ to avoid libc++ compiler error. The CI should pass and the PR is ready to merge now, @acassis and @gustavonihei please take a look.


-- 
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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153#issuecomment-880535223


   CI fail due to libstdc++ call utimensat wrongly:
   https://github.com/llvm/llvm-project/blob/main/libcxx/src/filesystem/filesystem_common.h#L30-L36
   Let's wait @Donny9 ' xxxat patch to fix this issue first.


-- 
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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153#issuecomment-888938594


   It pass CI except "Mix case" warning, @gustavonihei please take a look.


-- 
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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153#discussion_r670046559



##########
File path: fs/vfs/fs_fchstat.c
##########
@@ -0,0 +1,286 @@
+/****************************************************************************
+ * fs/vfs/fs_fchstat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <nuttx/fs/fs.h>
+
+#include "inode/inode.h"
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: fchstat
+ ****************************************************************************/
+
+static int fchstat(int fd, FAR struct stat *buf, int flags)
+{
+  FAR struct file *filep;
+  int ret;
+
+  /* First, get the file structure.  Note that on failure,
+   * fs_getfilep() will return the errno.
+   */
+
+  ret = fs_getfilep(fd, &filep);
+  if (ret < 0)
+    {
+      goto errout;
+    }
+
+  /* Perform the fchstat operation */
+
+  ret = file_fchstat(filep, buf, flags);
+
+  /* Check if the fchstat operation was successful */
+
+  if (ret >= 0)
+    {
+      /* Successfully fchstat'ed the file */
+
+      return OK;
+    }
+
+errout:
+  set_errno(-ret);
+  return ERROR;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: file_fchstat
+ *
+ * Description:
+ *   file_fchstat() is an internal OS interface. It is functionally similar
+ *   to the combination of fchmod/fchown/futimens standard interface except:
+ *
+ *    - It does not modify the errno variable,
+ *    - It is not a cancellation point,
+ *    - It does not handle socket descriptors, and
+ *    - It accepts a file structure instance instead of file descriptor.
+ *
+ * Input Parameters:
+ *   filep  - File structure instance
+ *   buf    - The stat to be modified
+ *   flags  - The vaild field in buf
+ *
+ * Returned Value:
+ *   Upon successful completion, 0 shall be returned. Otherwise, the
+ *   negative errno shall be returned to indicate the error.
+ *
+ ****************************************************************************/
+
+int file_fchstat(FAR struct file *filep, FAR struct stat *buf, int flags)
+{
+  FAR struct inode *inode;
+  int ret;
+
+  DEBUGASSERT(filep != NULL);
+
+  /* Get the inode from the file structure */
+
+  inode = filep->f_inode;
+  DEBUGASSERT(inode != NULL);
+
+  /* Adjust and check buf and flags */
+
+  if ((flags & CH_STAT_MODE) && (buf->st_mode & ~07777))

Review comment:
       the up 4bits is used to repesent file type and can not be modified by caller, this check ensure it.




-- 
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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153#discussion_r670048353



##########
File path: fs/vfs/fs_fchstat.c
##########
@@ -0,0 +1,286 @@
+/****************************************************************************
+ * fs/vfs/fs_fchstat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <nuttx/fs/fs.h>
+
+#include "inode/inode.h"
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: fchstat
+ ****************************************************************************/
+
+static int fchstat(int fd, FAR struct stat *buf, int flags)
+{
+  FAR struct file *filep;
+  int ret;
+
+  /* First, get the file structure.  Note that on failure,
+   * fs_getfilep() will return the errno.

Review comment:
       I can not understand your meaning, do you want me change the comment? but the comment is right becasue fs_getfilep do not set errno in failure path.




-- 
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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153#issuecomment-888503541


   > CI fail due to libstdc++ call utimensat wrongly:
   > https://github.com/llvm/llvm-project/blob/main/libcxx/src/filesystem/filesystem_common.h#L30-L36
   > Let's wait @Donny9 ' xxxat patch to fix this issue first.
   
   Since utimensat need more time to support, I add a new patch to temporarily undefine UTIME_OMIT in C++ to avoid libc++ compiler error. The CI should pass and the PR is ready to merge, @acassis and @gustavonihei please take a look.


-- 
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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153#discussion_r670193936



##########
File path: fs/vfs/fs_fchstat.c
##########
@@ -0,0 +1,286 @@
+/****************************************************************************
+ * fs/vfs/fs_fchstat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <nuttx/fs/fs.h>
+
+#include "inode/inode.h"
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: fchstat
+ ****************************************************************************/
+
+static int fchstat(int fd, FAR struct stat *buf, int flags)
+{
+  FAR struct file *filep;
+  int ret;
+
+  /* First, get the file structure.  Note that on failure,
+   * fs_getfilep() will return the errno.
+   */
+
+  ret = fs_getfilep(fd, &filep);
+  if (ret < 0)
+    {
+      goto errout;
+    }
+
+  /* Perform the fchstat operation */
+
+  ret = file_fchstat(filep, buf, flags);
+
+  /* Check if the fchstat operation was successful */
+

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

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



[GitHub] [incubator-nuttx] acassis commented on a change in pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
acassis commented on a change in pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153#discussion_r669756455



##########
File path: fs/vfs/fs_fchstat.c
##########
@@ -0,0 +1,286 @@
+/****************************************************************************
+ * fs/vfs/fs_fchstat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <nuttx/fs/fs.h>
+
+#include "inode/inode.h"
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: fchstat
+ ****************************************************************************/
+
+static int fchstat(int fd, FAR struct stat *buf, int flags)
+{
+  FAR struct file *filep;
+  int ret;
+
+  /* First, get the file structure.  Note that on failure,
+   * fs_getfilep() will return the errno.

Review comment:
       It is not returning the "errno", but setting the errno and returning ERROR (-1). Please find this comment.

##########
File path: fs/vfs/fs_fchstat.c
##########
@@ -0,0 +1,286 @@
+/****************************************************************************
+ * fs/vfs/fs_fchstat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <nuttx/fs/fs.h>
+
+#include "inode/inode.h"
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: fchstat
+ ****************************************************************************/
+
+static int fchstat(int fd, FAR struct stat *buf, int flags)
+{
+  FAR struct file *filep;
+  int ret;
+
+  /* First, get the file structure.  Note that on failure,
+   * fs_getfilep() will return the errno.
+   */
+
+  ret = fs_getfilep(fd, &filep);
+  if (ret < 0)
+    {
+      goto errout;
+    }
+
+  /* Perform the fchstat operation */
+
+  ret = file_fchstat(filep, buf, flags);
+
+  /* Check if the fchstat operation was successful */
+

Review comment:
       Remove remove this comment (it is not necessary here), just:
     ret = file_fchstat(filep, buf, flags);
     if (ret >= 0)
       {
         /* Successfully fchstat'ed the file */
   
         return OK;
       }

##########
File path: fs/vfs/fs_fchstat.c
##########
@@ -0,0 +1,286 @@
+/****************************************************************************
+ * fs/vfs/fs_fchstat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <nuttx/fs/fs.h>
+
+#include "inode/inode.h"
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: fchstat
+ ****************************************************************************/
+
+static int fchstat(int fd, FAR struct stat *buf, int flags)
+{
+  FAR struct file *filep;
+  int ret;
+
+  /* First, get the file structure.  Note that on failure,
+   * fs_getfilep() will return the errno.
+   */
+
+  ret = fs_getfilep(fd, &filep);
+  if (ret < 0)
+    {
+      goto errout;
+    }
+
+  /* Perform the fchstat operation */
+
+  ret = file_fchstat(filep, buf, flags);
+
+  /* Check if the fchstat operation was successful */
+
+  if (ret >= 0)
+    {
+      /* Successfully fchstat'ed the file */
+
+      return OK;
+    }
+
+errout:
+  set_errno(-ret);
+  return ERROR;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: file_fchstat
+ *
+ * Description:
+ *   file_fchstat() is an internal OS interface. It is functionally similar
+ *   to the combination of fchmod/fchown/futimens standard interface except:
+ *
+ *    - It does not modify the errno variable,
+ *    - It is not a cancellation point,
+ *    - It does not handle socket descriptors, and
+ *    - It accepts a file structure instance instead of file descriptor.
+ *
+ * Input Parameters:
+ *   filep  - File structure instance
+ *   buf    - The stat to be modified
+ *   flags  - The vaild field in buf
+ *
+ * Returned Value:
+ *   Upon successful completion, 0 shall be returned. Otherwise, the
+ *   negative errno shall be returned to indicate the error.
+ *
+ ****************************************************************************/
+
+int file_fchstat(FAR struct file *filep, FAR struct stat *buf, int flags)
+{
+  FAR struct inode *inode;
+  int ret;
+
+  DEBUGASSERT(filep != NULL);
+
+  /* Get the inode from the file structure */
+
+  inode = filep->f_inode;
+  DEBUGASSERT(inode != NULL);
+
+  /* Adjust and check buf and flags */
+
+  if ((flags & CH_STAT_MODE) && (buf->st_mode & ~07777))

Review comment:
       I think this test could always return true: (buf->st_mode & ~07777)
   st_mode is of type mode_t that is 16-bit, but 07777 octal value is only 12-bit long, so if the upper 4 bits from st_mode are 0 the resulting value will be different of zero. Did you check it?




-- 
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



[GitHub] [incubator-nuttx] gustavonihei merged pull request #4153: fs: Add fchstat and chstat callback into mountpt_operations

Posted by GitBox <gi...@apache.org>.
gustavonihei merged pull request #4153:
URL: https://github.com/apache/incubator-nuttx/pull/4153


   


-- 
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