| 1263 | } |
| 1264 | |
| 1265 | static int doTruncate(std::shared_ptr<File>& file, off_t size) { |
| 1266 | auto dataFile = file->dynCast<DataFile>(); |
| 1267 | |
| 1268 | if (!dataFile) { |
| 1269 | return -EISDIR; |
| 1270 | } |
| 1271 | |
| 1272 | auto locked = dataFile->locked(); |
| 1273 | if (!(locked.getMode() & WASMFS_PERM_WRITE)) { |
| 1274 | return -EACCES; |
| 1275 | } |
| 1276 | |
| 1277 | if (size < 0) { |
| 1278 | return -EINVAL; |
| 1279 | } |
| 1280 | |
| 1281 | int ret = locked.setSize(size); |
| 1282 | assert(ret <= 0); |
| 1283 | return ret; |
| 1284 | } |
| 1285 | |
| 1286 | int __syscall_truncate64(const char* path, off_t length) { |
| 1287 | auto parsed = path::parseFile(path); |
no test coverage detected