All of lore.kernel.org
 help / color / mirror / Atom feed
* /fs/ext4/namei.c ext4_find_dest_de()
@ 2020-05-03 13:00 Jonny Grant
  2020-05-04  1:51 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 10+ messages in thread
From: Jonny Grant @ 2020-05-03 13:00 UTC (permalink / raw)
  To: linux-ext4

Hi

I noticed that mkdir() returns EEXIST if a directory already exists. 
strerror(EEXIST) text is "File exists"

Can ext4_find_dest_de() be amended to return EISDIR if a directory 
already exists? This will make the error message clearer.

This is the line of code from ext4_find_dest_de():

if (ext4_match(dir, fname, de))
			return -EEXIST;



I propose to change to something like the following:


int ext4_match_result = ext4_match(dir, fname, de);

		nlen = EXT4_DIR_REC_LEN(de->name_len);
		rlen = ext4_rec_len_from_disk(de->rec_len, buf_size);
		if ((de->inode ? rlen - nlen : rlen) >= reclen)
			break;
		de = (struct ext4_dir_entry_2 *)((char *)de + rlen);

if (ext4_match_result)
{
     if(EXT4_FT_DIR == de->file_type)
     {
         return -EISDIR;
     }
     else
     {
	return -EEXIST;
     }
}



Let me know if this would be supported, and I can prepare a patch.

Cheers
Jonny

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-06-08  1:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 13:00 /fs/ext4/namei.c ext4_find_dest_de() Jonny Grant
2020-05-04  1:51 ` Theodore Y. Ts'o
2020-05-04  7:38   ` Jonny Grant
2020-05-04 19:52     ` Theodore Y. Ts'o
2020-05-05 18:07       ` Jonny Grant
2020-05-05 18:50         ` Andreas Dilger
2020-05-07 11:25           ` Jonny Grant
2020-05-27 21:25   ` Jonny Grant
2020-05-28  1:12     ` Theodore Y. Ts'o
2020-06-08  1:39       ` Jonny Grant

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.