Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc

Issue 660353003: [NaCl SDK] nacl_io: Fix utime() on directories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "nacl_io/kernel_proxy.h" 5 #include "nacl_io/kernel_proxy.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <limits.h> 10 #include <limits.h>
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 int KernelProxy::truncate(const char* path, off_t len) { 785 int KernelProxy::truncate(const char* path, off_t len) {
786 ScopedFilesystem fs; 786 ScopedFilesystem fs;
787 ScopedNode node; 787 ScopedNode node;
788 788
789 Error error = AcquireFsAndNode(path, O_WRONLY, 0, &fs, &node); 789 Error error = AcquireFsAndNode(path, O_WRONLY, 0, &fs, &node);
790 if (error) { 790 if (error) {
791 errno = error; 791 errno = error;
792 return -1; 792 return -1;
793 } 793 }
794 794
795 // Directories cannot be truncated.
796 if (node->IsaDir()) {
797 return EISDIR;
798 }
799
795 if (!node->CanOpen(O_WRONLY)) { 800 if (!node->CanOpen(O_WRONLY)) {
796 errno = EACCES; 801 errno = EACCES;
797 return -1; 802 return -1;
798 } 803 }
799 804
800 error = node->FTruncate(len); 805 error = node->FTruncate(len);
801 if (error) { 806 if (error) {
802 errno = error; 807 errno = error;
803 return -1; 808 return -1;
804 } 809 }
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 errno = ENOTSOCK; 1817 errno = ENOTSOCK;
1813 return -1; 1818 return -1;
1814 } 1819 }
1815 1820
1816 return 0; 1821 return 0;
1817 } 1822 }
1818 1823
1819 #endif // PROVIDES_SOCKET_API 1824 #endif // PROVIDES_SOCKET_API
1820 1825
1821 } // namespace_nacl_io 1826 } // namespace_nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/kernel_handle.cc ('k') | native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698