src/server/daemon/vfs.c

changeset 171
af7e2d80dee6
parent 105
63d9051fe35c
child 193
aa8393527b1e
equal deleted inserted replaced
169:76c96ee18221 171:af7e2d80dee6
30 30
31 #include <stdio.h> 31 #include <stdio.h>
32 #include <stdlib.h> 32 #include <stdlib.h>
33 #include <unistd.h> 33 #include <unistd.h>
34 #include <sys/types.h> 34 #include <sys/types.h>
35
36 #include <ucx/map.h> 35 #include <ucx/map.h>
37 36
38 #include "../util/pool.h" 37 #include "../util/pool.h"
38 #include "netsite.h"
39 #include "acl.h" 39 #include "acl.h"
40 #include "vfs.h" 40 #include "vfs.h"
41 41
42 static UcxMap *vfs_map; 42 static UcxMap *vfs_map;
43 43
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;

mercurial