static void epm_error_saving_file(struct epm_action *action, int error,
				  struct task_struct *task, struct file *file,
				  int index)
{
	char *buffer, *filename;
	filename = alloc_filename(file, &buffer);
	if (!IS_ERR(filename)) {
		epm_error(action, error, task,
			  "Fail to save information about file %s "
			  "as fd %d", filename, index);
		free_filename(buffer);
	} else {
		epm_error(action, error, task,
			  "Fail to save information about fd %d",
			  index);
	}
}
示例#2
0
static void
binary_protocol_check_file_overflow (void)
{
	if (file_size_limit <= 0 || current_file_size < file_size_limit)
		return;

	close_binary_protocol_file ();

	if (current_file_index > 0) {
		char *filename = filename_for_index (current_file_index - 1);
		unlink (filename);
		free_filename (filename);
	}

	++current_file_index;
	current_file_size = 0;

	binary_protocol_open_file ();
}
示例#3
0
static void
binary_protocol_open_file (void)
{
	char *filename;

	if (file_size_limit > 0)
		filename = filename_for_index (current_file_index);
	else
		filename = filename_or_prefix;

	do {
		binary_protocol_file = open (filename, O_CREAT|O_WRONLY|O_TRUNC, 0644);
		if (binary_protocol_file == -1 && errno != EINTR)
			break; /* Failed */
	} while (binary_protocol_file == -1);

	if (file_size_limit > 0)
		free_filename (filename);
}
示例#4
0
static void
binary_protocol_open_file (gboolean assert_on_failure)
{
	char *filename;
#ifdef F_SETLK
	struct flock lock;
	lock.l_type = F_WRLCK;
	lock.l_whence = SEEK_SET;
	lock.l_start = 0;
	lock.l_len = 0;
#endif

	if (file_size_limit > 0)
		filename = filename_for_index (current_file_index);
	else
		filename = filename_or_prefix;

	do {
		binary_protocol_file = open (filename, O_CREAT | O_WRONLY, 0644);
		if (binary_protocol_file == -1) {
			if (errno != EINTR)
				break; /* Failed */
#ifdef F_SETLK
		} else if (fcntl (binary_protocol_file, F_SETLK, &lock) == -1) {
			/* The lock for the file is already taken. Fail */
			close (binary_protocol_file);
			binary_protocol_file = -1;
			break;
#endif
		} else {
			/* We have acquired the lock. Truncate the file */
			ftruncate (binary_protocol_file, 0);
		}
	} while (binary_protocol_file == -1);

	if (binary_protocol_file == -1 && assert_on_failure)
		g_error ("sgen binary protocol: failed to open file");

	if (file_size_limit > 0)
		free_filename (filename);
}
示例#5
0
static int cr_export_now_file(struct epm_action *action, ghost_t *ghost,
			      struct task_struct *task,
			      union export_args *args)
{
	int r, supported;

	supported = can_checkpoint_file(args->file_args.file);

	r = ghost_write(ghost, &supported, sizeof(supported));
	if (r)
		goto error;

	if (supported)
		r = regular_file_export(action, ghost, task,
					args->file_args.index,
					args->file_args.file);

error:
	if (r) {
		char *buffer, *filename;
		filename = alloc_filename(args->file_args.file, &buffer);
		if (!IS_ERR(filename)) {
			ckpt_err(action, r,
				 "Fail to save information needed to reopen "
				 "file %s as fd %d of process %d (%s)",
				 filename, args->file_args.index,
				 task_pid_knr(task), task->comm);
			free_filename(buffer);
		} else {
			ckpt_err(action, r,
				 "Fail to save information needed to reopen "
				 "fd %d of process %d (%s)",
				 args->file_args.index,
				 task_pid_knr(task), task->comm);
		}
	}

	return r;
}
示例#6
0
bool free_dialog(void)
{
    free_filename();
    return true;
}