コード例 #1
0
ファイル: zcalls_zrt.c プロジェクト: kangaroo/zrt
int  zrt_zcall_enhanced_open(const char *name, int flags, mode_t mode, int *newfd){
    LOG_SYSCALL_START("name=%s flags=%d mode=%o(octal)", name, flags, mode );

    char* absolute_path;
    char temp_path[PATH_MAX];
    int ret=-1;
    errno=0;
    VALIDATE_SYSCALL_PTR(name);
    
    /*reset mode bits, that is not actual for permissions*/
    mode&=(S_IRWXU|S_IRWXG|S_IRWXO);
    APPLY_UMASK(&mode);

    if ( (absolute_path = zrealpath(name, temp_path)) != NULL ){
	ZRT_LOG(L_SHORT, "absolute_path=%s", absolute_path);
	if ( (ret = s_transparent_mount->open(s_transparent_mount, absolute_path, flags, mode )) >= 0 ){
	    /*get fd by pointer*/
	    *newfd  = ret;
	    ret =0;
	}
    }

    LOG_SHORT_SYSCALL_FINISH( ret, 
			      "*newfd=%d, name=%s, flags=%s, mode=%s", 
			      *newfd, name, 
			      STR_ALLOCA_COPY(STR_FILE_OPEN_FLAGS(flags)),
			      STR_ALLOCA_COPY(STR_STAT_ST_MODE(mode)));
    return ret;
}
コード例 #2
0
ファイル: rename.c プロジェクト: VanL/zrt
int zrt_zcall_rename (const char *oldpath, const char *newpath){
    CHECK_EXIT_IF_ZRT_NOT_READY;
    char* absolute_path1;
    char* absolute_path2;
    char temp_path1[PATH_MAX];
    char temp_path2[PATH_MAX];
    int ret=-1;
    errno=0;
    LOG_SYSCALL_START("old=%p, new=%p", oldpath, newpath);
    
    struct MountsPublicInterface* transpar_mount = transparent_mount();
    assert(transpar_mount);

    VALIDATE_SUBSTITUTED_SYSCALL_PTR(oldpath);
    VALIDATE_SUBSTITUTED_SYSCALL_PTR(newpath);
    if ( (absolute_path1 = realpath(oldpath, temp_path1)) != NULL &&
	 (absolute_path2 = zrealpath(newpath, temp_path2)) != NULL){
	ret = transpar_mount->rename(transpar_mount, absolute_path1, absolute_path2);
    }

    LOG_SHORT_SYSCALL_FINISH(ret, "old=%s, new=%s", oldpath, newpath);
    return ret;
}