Exemplo n.º 1
0
INTERPOSE (close, int, int fd)
{
  CHECK_INTERPOSE (close);

  unregister_fd (fd);

  return orig_close (fd);
}
Exemplo n.º 2
0
int close(int fd) {
    if (!orig_close) preload_init();

    TRACE("close %d\n", fd);

    if (fd == tty0fd) {
        tty0fd = -1;
    } else if (fd == tty7fd) {
        tty7fd = -1;
    }
    return orig_close(fd);
}
Exemplo n.º 3
0
/*
int creat(const char *pathname, mode_t mode)
{
	orig_creat_type orig_creat;
	orig_creat = (orig_creat_type)dlsym(RTLD_NEXT,"creat");

	clock_t start = clock();

		int fd = orig_creat(pathname,mode);

	clock_t end = clock();

		double start_diff = ((double)(start-program_start))/(double)CLOCKS_PER_SEC;
		double end_diff = ((double)(end-program_start))/(double)CLOCKS_PER_SEC;

		return fd;
}

int open(const char *pathname, int flags)
{

	orig_open_type orig_open;
	orig_open = (orig_open_type)dlsym(RTLD_NEXT,"open");

	clock_t start = clock();

		int fd = orig_open(pathname,flags);

	clock_t end = clock();

		double start_diff = ((double)(start-program_start))/(double)CLOCKS_PER_SEC;
		double end_diff = ((double)(end-program_start))/(double)CLOCKS_PER_SEC;

		return fd;

}


int open(const char *pathname, int flags, mode_t mode)
{

		orig_open2_type orig_open2;
	orig_open2 = (orig_open2_type)dlsym(RTLD_NEXT,"open");

		clock_t start = clock();

		int fd = orig_open2(pathname,flags,mode);

		clock_t end = clock();

		double start_diff = ((double)(start-program_start))/(double)CLOCKS_PER_SEC;
		double end_diff = ((double)(end-program_start))/(double)CLOCKS_PER_SEC;

		return fd;

}
*/
int close(int fd)
{
	orig_close_type orig_close;
	orig_close = (orig_close_type)dlsym(RTLD_NEXT,"close");

	clock_t start = clock();

		int temp = orig_close(fd);

	clock_t end = clock();

		double start_diff = ((double)(start-program_start))/(double)CLOCKS_PER_SEC;
		double end_diff = ((double)(end-program_start))/(double)CLOCKS_PER_SEC;
		printf("%lf %lf Close Called \n", start_diff, end_diff);
		return temp;
}
Exemplo n.º 4
0
/* Grabs the system-wide lockfile that arbitrates which chroot is using the GPU.
 *
 * pid should be either the pid of the process that owns the GPU (eg. getpid()),
 * or 0 to indicate that Chromium OS now owns the GPU.
 *
 * Returns 0 on success, or -1 on error.
 */
static int set_display_lock(unsigned int pid) {
    if (lockfd == -1) {
        if (pid == 0) {
            ERROR("No display lock to release.\n");
            return 0;
        }
        (void) mkdir(LOCK_FILE_DIR, 0777);
        lockfd = orig_open(DISPLAY_LOCK_FILE, O_CREAT | O_WRONLY, 0666);
        if (lockfd == -1) {
            ERROR("Unable to open display lock file.\n");
            return -1;
        }
        if (flock(lockfd, LOCK_EX) == -1) {
            ERROR("Unable to lock display lock file.\n");
            return -1;
        }
    }
    if (ftruncate(lockfd, 0) == -1) {
        ERROR("Unable to truncate display lock file.\n");
        return -1;
    }
    char buf[11];
    int len;
    if ((len = snprintf(buf, sizeof(buf), "%d\n", pid)) < 0) {
        ERROR("pid sprintf failed.\n");
        return -1;
    }
    if (write(lockfd, buf, len) == -1) {
        ERROR("Unable to write to display lock file.\n");
        return -1;
    }
    if (pid == 0) {
        int ret = orig_close(lockfd);
        lockfd = -1;
        if (ret == -1) {
            ERROR("Failure when closing display lock file.\n");
        }
        return ret;
    }
    return 0;
}
Exemplo n.º 5
0
/* Prevents some glitch if Chromium OS keeps cursor enabled (#2878). */
static void drm_disable_cursor()
{
    int i, fd;
    drmModeRes* resources;

    if (!orig_open) preload_init();

    fd = orig_open("/dev/dri/card0", O_RDWR, 0);

    TRACE("%s %d\n", __func__, fd);

    if (fd < 0)
        return;

    resources = drmModeGetResources(fd);
    if (!resources)
        goto closefd;

    TRACE("%s res=%p\n", __func__, resources);
    for (i = 0; i < resources->count_crtcs; i++) {
        drmModeCrtc* crtc;

        crtc = drmModeGetCrtc(fd, resources->crtcs[i]);
        TRACE("%s crtc %d %p\n", __func__, i, crtc);
        if (crtc) {
            drmModeSetCursor(fd, crtc->crtc_id,
                             0, 0, 0);
            drmModeFreeCrtc(crtc);
        }
    }

    drmModeFreeResources(resources);

closefd:
    orig_close(fd);
}
Exemplo n.º 6
0
asmlinkage ssize_t our_close(int fd) 
{
        printk(KERN_INFO "SYS_CLOSE %s\n",current->comm);
        return orig_close(fd);
}