Beispiel #1
0
void LogFlush(void)
{
  if (logfile && log_written)
  {
    log_written=FALSE;

    fflush(logfile);
    flush_handle(logfile);
  }
}
Beispiel #2
0
int shim_do_truncate (const char * path, loff_t length)
{
    struct shim_dentry * dent = NULL;
    int ret = 0;

    if (!path || test_user_string(path))
        return -EFAULT;

    if ((ret = path_lookupat(NULL, path, 0, &dent, NULL)) < 0)
        return ret;

    struct shim_mount * fs = dent->fs;

    if (!fs || !fs->d_ops || !fs->d_ops->open) {
        ret = -EBADF;
        goto out;
    }

    if (!fs->fs_ops->truncate) {
        ret = -EROFS;
        goto out;
    }

    struct shim_handle * hdl = get_new_handle();

    if (!hdl) {
        ret = -ENOMEM;
        goto out;
    }

    hdl->fs = fs;

    if ((ret = fs->d_ops->open(hdl, dent, O_WRONLY)) < 0)
        goto out_handle;

    ret = fs->fs_ops->truncate(hdl, length);
    flush_handle(hdl);
out_handle:
    put_handle(hdl);
out:
    return ret;
}