Rev 2748 | Rev 2752 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2748 | Rev 2749 | ||
---|---|---|---|
Line 361... | Line 361... | ||
361 | else |
361 | else |
362 | rwlock_read_unlock(&namespace_rwlock); |
362 | rwlock_read_unlock(&namespace_rwlock); |
363 | 363 | ||
364 | /* Truncate the file if requested and if necessary. */ |
364 | /* Truncate the file if requested and if necessary. */ |
365 | if (oflag & O_TRUNC) { |
365 | if (oflag & O_TRUNC) { |
366 | futex_down(&node->contents_rwlock); |
366 | rwlock_write_lock(&node->contents_rwlock); |
367 | if (node->size) { |
367 | if (node->size) { |
368 | rc = vfs_truncate_internal(node->fs_handle, |
368 | rc = vfs_truncate_internal(node->fs_handle, |
369 | node->dev_handle, node->index, 0); |
369 | node->dev_handle, node->index, 0); |
370 | if (rc) { |
370 | if (rc) { |
371 | futex_up(&node->contents_rwlock); |
371 | rwlock_write_unlock(&node->contents_rwlock); |
372 | vfs_node_put(node); |
372 | vfs_node_put(node); |
373 | ipc_answer_0(rid, rc); |
373 | ipc_answer_0(rid, rc); |
374 | return; |
374 | return; |
375 | } |
375 | } |
376 | node->size = 0; |
376 | node->size = 0; |
377 | } |
377 | } |
378 | futex_up(&node->contents_rwlock); |
378 | rwlock_write_unlock(&node->contents_rwlock); |
379 | } |
379 | } |
380 | 380 | ||
381 | /* |
381 | /* |
382 | * Get ourselves a file descriptor and the corresponding vfs_file_t |
382 | * Get ourselves a file descriptor and the corresponding vfs_file_t |
383 | * structure. |
383 | * structure. |