mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Added error code LFS_ERR_NOTEMPTY
As noted by itayzafrir, removing a non-empty directory should error with ENOTEMPTY, not EINVAL
This commit is contained in:
		
							
								
								
									
										2
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -1740,7 +1740,7 @@ int lfs_remove(lfs_t *lfs, const char *path) { | ||||
|         if (err) { | ||||
|             return err; | ||||
|         } else if (dir.d.size != sizeof(dir.d)+4) { | ||||
|             return LFS_ERR_INVAL; | ||||
|             return LFS_ERR_NOTEMPTY; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
							
								
								
									
										1
									
								
								lfs.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								lfs.h
									
									
									
									
									
								
							| @@ -48,6 +48,7 @@ enum lfs_error { | ||||
|     LFS_ERR_EXIST    = -17,  // Entry already exists | ||||
|     LFS_ERR_NOTDIR   = -20,  // Entry is not a dir | ||||
|     LFS_ERR_ISDIR    = -21,  // Entry is a dir | ||||
|     LFS_ERR_NOTEMPTY = -39,  // Dir is not empty | ||||
|     LFS_ERR_INVAL    = -22,  // Invalid parameter | ||||
|     LFS_ERR_NOSPC    = -28,  // No space left on device | ||||
|     LFS_ERR_NOMEM    = -12,  // No more memory available | ||||
|   | ||||
| @@ -126,7 +126,7 @@ TEST | ||||
| echo "--- Directory remove ---" | ||||
| tests/test.py << TEST | ||||
|     lfs_mount(&lfs, &cfg) => 0; | ||||
|     lfs_remove(&lfs, "potato") => LFS_ERR_INVAL; | ||||
|     lfs_remove(&lfs, "potato") => LFS_ERR_NOTEMPTY; | ||||
|     lfs_remove(&lfs, "potato/sweet") => 0; | ||||
|     lfs_remove(&lfs, "potato/baked") => 0; | ||||
|     lfs_remove(&lfs, "potato/fried") => 0; | ||||
| @@ -255,7 +255,7 @@ tests/test.py << TEST | ||||
|     lfs_rename(&lfs, "warmpotato/baked", "coldpotato/baked") => 0; | ||||
|     lfs_rename(&lfs, "warmpotato/sweet", "coldpotato/sweet") => 0; | ||||
|     lfs_rename(&lfs, "warmpotato/fried", "coldpotato/fried") => 0; | ||||
|     lfs_remove(&lfs, "coldpotato") => LFS_ERR_INVAL; | ||||
|     lfs_remove(&lfs, "coldpotato") => LFS_ERR_NOTEMPTY; | ||||
|     lfs_remove(&lfs, "warmpotato") => 0; | ||||
|     lfs_unmount(&lfs) => 0; | ||||
| TEST | ||||
| @@ -285,7 +285,7 @@ TEST | ||||
| echo "--- Recursive remove ---" | ||||
| tests/test.py << TEST | ||||
|     lfs_mount(&lfs, &cfg) => 0; | ||||
|     lfs_remove(&lfs, "coldpotato") => LFS_ERR_INVAL; | ||||
|     lfs_remove(&lfs, "coldpotato") => LFS_ERR_NOTEMPTY; | ||||
|  | ||||
|     lfs_dir_open(&lfs, &dir[0], "coldpotato") => 0; | ||||
|     lfs_dir_read(&lfs, &dir[0], &info) => 1; | ||||
| @@ -328,7 +328,7 @@ TEST | ||||
| echo "--- Multi-block remove ---" | ||||
| tests/test.py << TEST | ||||
|     lfs_mount(&lfs, &cfg) => 0; | ||||
|     lfs_remove(&lfs, "cactus") => LFS_ERR_INVAL; | ||||
|     lfs_remove(&lfs, "cactus") => LFS_ERR_NOTEMPTY; | ||||
|  | ||||
|     for (int i = 0; i < $LARGESIZE; i++) { | ||||
|         sprintf((char*)buffer, "cactus/test%d", i); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user