phoenix-rtos / phoenix-rtos-project

Sample project using Phoenix-RTOS
https://phoenix-rtos.com
BSD 3-Clause "New" or "Revised" License
45 stars 32 forks source link

pext2, dummyfs, jffs2: truncate sets wrong errno, when passing a directory in the `path` argument #573

Open damianloew opened 1 year ago

damianloew commented 1 year ago

int main(void) { int ret;

ret = truncate("/dev", 0);
printf("Return code = %d, error: %s\n", ret, strerror(errno));

return 0;

}


 - Result (ext2, ia32-generic-qemu): 

![Screenshot from 2022-12-13 19-25-16](https://user-images.githubusercontent.com/77304431/207415774-63e631dc-2490-4f05-9716-78de33f8284e.png)

 - Result (dummyfs, armv7m7-imxrt106x-evk):

![Screenshot from 2022-12-14 11-44-29](https://user-images.githubusercontent.com/77304431/207574651-226dc1f7-f87d-44e6-9c7d-2c8fa7b626a9.png)

 - According to POSIX it should set the `EISDIR` errno.

 - Tested on `ia32-generic-qemu`

- That's probably the following case: 
  - https://github.com/phoenix-rtos/phoenix-rtos-filesystems/blob/73b4f1b958dff14f3a387d56cb58e957e384e5bc/ext2/ext2.c#L241-L242
  - https://github.com/phoenix-rtos/phoenix-rtos-filesystems/blob/73b4f1b958dff14f3a387d56cb58e957e384e5bc/dummyfs/dummyfs.c#L653-L655
nalajcie commented 1 year ago

I think this error is returned by a particular filesystem server - not the libphoenix part, please update the description with FS the bug happens on - and try to check other FSes if it reproduces there.

Also - the issue title is misleading - the error is not about an absolute path, but about trying to truncate a directory.

agkaminski commented 1 year ago

Fixed in https://github.com/phoenix-rtos/phoenix-rtos-filesystems/pull/92

mateusz-bloch commented 1 year ago

Problem occures on jjfs2