144 |
144 |
145 // if a file system acl is active, we set the owner for newly created files |
145 // if a file system acl is active, we set the owner for newly created files |
146 if(((oflags & O_CREAT) == O_CREAT) && sysacl.user_uid != -1) { |
146 if(((oflags & O_CREAT) == O_CREAT) && sysacl.user_uid != -1) { |
147 if(fchown(fd, sysacl.user_uid, sysacl.user_gid)) { |
147 if(fchown(fd, sysacl.user_uid, sysacl.user_gid)) { |
148 perror("vfs_open: fchown"); |
148 perror("vfs_open: fchown"); |
149 close(fd); |
149 system_close(fd); |
150 return NULL; |
150 return NULL; |
151 } |
151 } |
152 } |
152 } |
153 |
153 |
154 |
154 |
155 VFSFile *file = pool ? |
155 VFSFile *file = pool ? |
156 pool_malloc(pool, sizeof(VFSFile)) : malloc(sizeof(VFSFile)); |
156 pool_malloc(pool, sizeof(VFSFile)) : malloc(sizeof(VFSFile)); |
157 if(!file) { |
157 if(!file) { |
158 close(fd); |
158 system_close(fd); |
159 return NULL; |
159 return NULL; |
160 } |
160 } |
161 file->ctx = ctx; |
161 file->ctx = ctx; |
162 file->data = NULL; |
162 file->data = NULL; |
163 file->fd = fd; |
163 file->fd = fd; |
485 off_t sys_file_seek(SYS_FILE fd, off_t offset, int whence) { |
485 off_t sys_file_seek(SYS_FILE fd, off_t offset, int whence) { |
486 return lseek(fd->fd, offset, whence); |
486 return lseek(fd->fd, offset, whence); |
487 } |
487 } |
488 |
488 |
489 void sys_file_close(SYS_FILE fd) { |
489 void sys_file_close(SYS_FILE fd) { |
490 close(fd->fd); |
490 system_close(fd->fd); |
491 } |
491 } |
492 |
492 |
493 int sys_dir_read(VFS_DIR dir, VFS_ENTRY *entry, int getstat) { |
493 int sys_dir_read(VFS_DIR dir, VFS_ENTRY *entry, int getstat) { |
494 SysVFSDir *dirdata = dir->data; |
494 SysVFSDir *dirdata = dir->data; |
495 struct dirent *result = NULL; |
495 struct dirent *result = NULL; |