This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0095009076 fs/nfs: fix offset in append mode and attributes after
create
0095009076 is described below
commit 0095009076a76a986820d0b0c7cb8cc6200ff5ab
Author: Alejandro Aguirre <[email protected]>
AuthorDate: Sat Oct 26 20:20:04 2024 +0200
fs/nfs: fix offset in append mode and attributes after create
- When opening a NFS file in append mode, its file pointer was at offset
0 instead of the end of file.
- When creating a NFS file, the response read pointer wasn't advanced
after reading the attributes_follows bool, which caused the attributes
to be off by 4 bytes. For example, the file size read the GID.
Signed-off-by: Alejandro Aguirre <[email protected]>
---
fs/nfs/nfs_vfsops.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/nfs_vfsops.c b/fs/nfs/nfs_vfsops.c
index dd2def7457..3a32bc03d2 100644
--- a/fs/nfs/nfs_vfsops.c
+++ b/fs/nfs/nfs_vfsops.c
@@ -367,7 +367,7 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, FAR
struct nfsnode *np,
/* Save the attributes in the file data structure */
- tmp = *ptr; /* attributes_follows */
+ tmp = *ptr++; /* attributes_follows */
if (!tmp)
{
fwarn("WARNING: no file attributes\n");
@@ -731,6 +731,15 @@ static int nfs_open(FAR struct file *filep, FAR const char
*relpath,
filep->f_priv = np;
+ /* In write/append mode, we need to set the file pointer to the end of
+ * the file.
+ */
+
+ if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
+ {
+ filep->f_pos = (off_t)np->n_size;
+ }
+
/* Then insert the new instance at the head of the list in the mountpoint
* structure. It needs to be there (1) to handle error conditions that
* effect all files, and (2) to inform the umount logic that we are busy.