[PATCH v2] erofs-utils: lib: correctly set {u,g}id in erofs_rebuild_make_root()

Gao Xiang hsiangkao at linux.alibaba.com
Wed Jan 14 19:09:26 AEDT 2026



On 2026/1/14 15:58, zhaoyifan (H) wrote:
> On 2026/1/14 15:44, Gao Xiang wrote:
> 
>> we could support !im, I mean
>>
>>     struct erofs_importer_params *params = im ? im->params : NULL;
> 
> Hi Xiang,
> 
> Do we have any chance `im == NULL` in current codebase? Or is it to allow for future extensibility?

Yes, also I wonder if we could give a better name, like

erofs_make_empty_root_inode()

> 
>>
>>>       struct erofs_inode *root;
>>>   @@ -2384,6 +2385,8 @@ struct erofs_inode *erofs_rebuild_make_root(struct erofs_sb_info *sbi)
>>>           return root;
>>>       root->i_srcpath = strdup("/");
>>>       root->i_mode = S_IFDIR | 0777;
>>> +    root->i_uid = im->params->fixed_uid == -1 ? getuid() : im->params->fixed_uid;
>>> +    root->i_gid = im->params->fixed_gid == -1 ? getgid() : im->params->fixed_gid;
>>
>>
>>
>>     root->i_uid = params && params->fixed_uid < 0 ? getuid() :
>>             params->fixed_uid;
> 
> will sigfault if `params == NULL`, how about
> 
>      root->i_uid = (!params || params->fixed_uid < 0) ? getuid() :
>                                 params->fixed_uid;

Sorry about my braino.

Thanks,
Gao Xiang

> 
> 
> Thanks,
> 
> Yifan
> 
>> ... 



More information about the Linux-erofs mailing list