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

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

Issue 565343002: [NaCl SDK] nacl_io: Plumb through {,f}utime{,s} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 char* KernelProxy::getwd(char* buf) { 318 char* KernelProxy::getwd(char* buf) {
319 if (NULL == buf) { 319 if (NULL == buf) {
320 errno = EFAULT; 320 errno = EFAULT;
321 return NULL; 321 return NULL;
322 } 322 }
323 return getcwd(buf, MAXPATHLEN); 323 return getcwd(buf, MAXPATHLEN);
324 } 324 }
325 325
326 int KernelProxy::chmod(const char* path, mode_t mode) { 326 int KernelProxy::chmod(const char* path, mode_t mode) {
327 int fd = KernelProxy::open(path, O_RDONLY, mode); 327 int fd = open(path, O_RDONLY, mode);
328 if (-1 == fd) 328 if (-1 == fd)
329 return -1; 329 return -1;
330 330
331 int result = fchmod(fd, mode); 331 int result = fchmod(fd, mode);
332 close(fd); 332 close(fd);
333 return result; 333 return result;
334 } 334 }
335 335
336 int KernelProxy::chown(const char* path, uid_t owner, gid_t group) { 336 int KernelProxy::chown(const char* path, uid_t owner, gid_t group) {
337 return 0; 337 return 0;
338 } 338 }
339 339
340 int KernelProxy::fchown(int fd, uid_t owner, gid_t group) { 340 int KernelProxy::fchown(int fd, uid_t owner, gid_t group) {
341 return 0; 341 return 0;
342 } 342 }
343 343
344 int KernelProxy::lchown(const char* path, uid_t owner, gid_t group) { 344 int KernelProxy::lchown(const char* path, uid_t owner, gid_t group) {
345 return 0; 345 return 0;
346 } 346 }
347 347
348 int KernelProxy::utime(const char* filename, const struct utimbuf* times) {
349 return 0;
350 }
351
352 int KernelProxy::mkdir(const char* path, mode_t mode) { 348 int KernelProxy::mkdir(const char* path, mode_t mode) {
353 ScopedFilesystem fs; 349 ScopedFilesystem fs;
354 Path rel; 350 Path rel;
355 351
356 Error error = AcquireFsAndRelPath(path, &fs, &rel); 352 Error error = AcquireFsAndRelPath(path, &fs, &rel);
357 if (error) { 353 if (error) {
358 errno = error; 354 errno = error;
359 return -1; 355 return -1;
360 } 356 }
361 357
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 669
674 error = handle->node()->VIoctl(request, args); 670 error = handle->node()->VIoctl(request, args);
675 if (error) { 671 if (error) {
676 errno = error; 672 errno = error;
677 return -1; 673 return -1;
678 } 674 }
679 675
680 return 0; 676 return 0;
681 } 677 }
682 678
679 int KernelProxy::futimens(int fd, const struct timespec times[2]) {
680 ScopedKernelHandle handle;
681 Error error = AcquireHandle(fd, &handle);
682 if (error) {
683 errno = error;
684 return -1;
685 }
686
687 error = handle->node()->Futimens(times);
688 if (error) {
689 errno = error;
690 return -1;
691 }
692
693 return 0;
694 }
695
683 off_t KernelProxy::lseek(int fd, off_t offset, int whence) { 696 off_t KernelProxy::lseek(int fd, off_t offset, int whence) {
684 ScopedKernelHandle handle; 697 ScopedKernelHandle handle;
685 Error error = AcquireHandle(fd, &handle); 698 Error error = AcquireHandle(fd, &handle);
686 if (error) { 699 if (error) {
687 errno = error; 700 errno = error;
688 return -1; 701 return -1;
689 } 702 }
690 703
691 off_t new_offset; 704 off_t new_offset;
692 error = handle->Seek(offset, whence, &new_offset); 705 error = handle->Seek(offset, whence, &new_offset);
(...skipping 18 matching lines...) Expand all
711 error = fs->Unlink(rel); 724 error = fs->Unlink(rel);
712 if (error) { 725 if (error) {
713 errno = error; 726 errno = error;
714 return -1; 727 return -1;
715 } 728 }
716 729
717 return 0; 730 return 0;
718 } 731 }
719 732
720 int KernelProxy::truncate(const char* path, off_t len) { 733 int KernelProxy::truncate(const char* path, off_t len) {
721 int fd = KernelProxy::open(path, O_WRONLY, 0); 734 int fd = open(path, O_WRONLY, 0);
722 if (-1 == fd) 735 if (-1 == fd)
723 return -1; 736 return -1;
724 737
725 int result = ftruncate(fd, len); 738 int result = ftruncate(fd, len);
726 close(fd); 739 close(fd);
727 return result; 740 return result;
728 } 741 }
729 742
730 int KernelProxy::lstat(const char* path, struct stat* buf) { 743 int KernelProxy::lstat(const char* path, struct stat* buf) {
731 return stat(path, buf); 744 return stat(path, buf);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 870
858 return 0; 871 return 0;
859 } 872 }
860 873
861 int KernelProxy::readlink(const char* path, char* buf, size_t count) { 874 int KernelProxy::readlink(const char* path, char* buf, size_t count) {
862 LOG_TRACE("readlink is not implemented."); 875 LOG_TRACE("readlink is not implemented.");
863 errno = EINVAL; 876 errno = EINVAL;
864 return -1; 877 return -1;
865 } 878 }
866 879
867 int KernelProxy::utimes(const char* filename, const struct timeval times[2]) { 880 int KernelProxy::utimens(const char* path, const struct timespec times[2]) {
868 LOG_TRACE("utimes is not implemented."); 881 int fd = open(path, O_RDONLY, 0);
869 errno = EINVAL; 882 if (-1 == fd)
870 return -1; 883 return -1;
884
885 int result = futimens(fd, times);
Sam Clegg 2014/09/12 21:36:27 Add explicit KernelProxy:: here to avoid confusion
binji 2014/09/12 21:50:07 We don't do that for open, close, stat, fstat, etc
886 close(fd);
887 return result;
871 } 888 }
872 889
873 // TODO(noelallen): Needs implementation. 890 // TODO(noelallen): Needs implementation.
874 int KernelProxy::link(const char* oldpath, const char* newpath) { 891 int KernelProxy::link(const char* oldpath, const char* newpath) {
875 LOG_TRACE("link is not implemented."); 892 LOG_TRACE("link is not implemented.");
876 errno = EINVAL; 893 errno = EINVAL;
877 return -1; 894 return -1;
878 } 895 }
879 896
880 int KernelProxy::symlink(const char* oldpath, const char* newpath) { 897 int KernelProxy::symlink(const char* oldpath, const char* newpath) {
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 errno = ENOTSOCK; 1734 errno = ENOTSOCK;
1718 return -1; 1735 return -1;
1719 } 1736 }
1720 1737
1721 return 0; 1738 return 0;
1722 } 1739 }
1723 1740
1724 #endif // PROVIDES_SOCKET_API 1741 #endif // PROVIDES_SOCKET_API
1725 1742
1726 } // namespace_nacl_io 1743 } // namespace_nacl_io
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698