Samuel Thibault <[email protected]> writes:

> Hello,
>
> Donjuanplatinum, le mar. 01 sept. 2026 10:45:06 +0800, a ecrit:
>> 
>> In incubator libfuse/master branch ,src/netfs.c lines 1436-1452:
>> 
>> 
>> /* using the inode based api */
>>       if(! strcmp(name, "."))
>>      inode = fuse_get_inode(handle->parent->path);
>> 
>>       else if(handle->parent->parent && ! strcmp(name, ".."))
>>      inode = fuse_get_inode(handle->parent->parent->path);
>> 
>>       if(! stat)
>>      {
>>        DEBUG("critical", "use_ino flag set, but stat ptr not available.\n");
>>        inode = 0;
>>      }
>> 
>>       else
>>      inode = stat->st_ino;
>> 
>> The "." and ".." cases might to be overridden by the handling of the
>> stat argument.
>> 
>> In either cases, the `inode` will be overridden by 0 or stat->st_ino. 
>
> It looks odd indeed, perhaps it just lacks an "else" before if (!stat)
>
> Samuel

Thanks! I have attached the small patch. I guess the "." and ".." branch
are fallback logic to assign the inode.

>From fa2c9894314cdd57c722b1caa2c9701cee7a877a Mon Sep 17 00:00:00 2001
From: Donjuanplatinum <[email protected]>
Date: Tue, 1 Sep 2026 10:13:00 +0800
Subject: [PATCH] libfuse: Fix inode assignment being overwritten

Avoid overwritting the inode obtained for "." and ".." when stat is
available.

* incubator/src/netfs.c branch libfuse/master: fix inode assignment being overwritten.

---
 src/netfs.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/netfs.c b/src/netfs.c
index 8d26d0158..110b3023f 100644
--- a/src/netfs.c
+++ b/src/netfs.c
@@ -1435,20 +1435,19 @@ get_dirents_readdir_helper(void *buf, const char *name,
   if(libfuse_params.use_ino)
     {
       /* using the inode based api */
-      if(! strcmp(name, "."))
+      if(stat)
+	inode = stat->st_ino;
+      /* stat is NULL, handle "." and ".." */
+      else if(! strcmp(name, "."))
 	inode = fuse_get_inode(handle->parent->path);
 
       else if(handle->parent->parent && ! strcmp(name, ".."))
 	inode = fuse_get_inode(handle->parent->parent->path);
-
-      if(! stat)
+      else
 	{
 	  DEBUG("critical", "use_ino flag set, but stat ptr not available.\n");
 	  inode = 0;
 	}
-
-      else
-	inode = stat->st_ino;
     }
   else
     {
-- 
2.55.0

Reply via email to