Exemplo n.º 1
0
void msg_close_file(struct messaging_context *msg_ctx,
			void *private_data,
			uint32_t msg_type,
			struct server_id server_id,
			DATA_BLOB *data)
{
	files_struct *fsp = NULL;
	struct share_mode_entry e;
	struct smbd_server_connection *sconn =
		talloc_get_type_abort(private_data,
		struct smbd_server_connection);

	message_to_share_mode_entry(&e, (char *)data->data);

	if(DEBUGLVL(10)) {
		char *sm_str = share_mode_str(NULL, 0, &e);
		if (!sm_str) {
			smb_panic("talloc failed");
		}
		DEBUG(10,("msg_close_file: got request to close share mode "
			"entry %s\n", sm_str));
		TALLOC_FREE(sm_str);
	}

	fsp = file_find_dif(sconn, e.id, e.share_file_id);
	if (!fsp) {
		DEBUG(10,("msg_close_file: failed to find file.\n"));
		return;
	}
	close_file(NULL, fsp, NORMAL_CLOSE);
}
Exemplo n.º 2
0
static files_struct *initial_break_processing(
	struct smbd_server_connection *sconn, struct file_id id,
	unsigned long file_id)
{
	files_struct *fsp = NULL;

	DEBUG(3, ("initial_break_processing: called for %s/%u\n"
		  "Current oplocks_open (exclusive = %d, levelII = %d)\n",
		  file_id_string_tos(&id), (int)file_id,
		  sconn->oplocks.exclusive_open,
		  sconn->oplocks.level_II_open));

	/*
	 * We need to search the file open table for the
	 * entry containing this dev and inode, and ensure
	 * we have an oplock on it.
	 */

	fsp = file_find_dif(sconn, id, file_id);

	if(fsp == NULL) {
		/* The file could have been closed in the meantime - return success. */
		DEBUG(3, ("initial_break_processing: cannot find open file "
			  "with file_id %s gen_id = %lu, allowing break to "
			  "succeed.\n", file_id_string_tos(&id), file_id));
		return NULL;
	}

	/* Ensure we have an oplock on the file */

	/*
	 * There is a potential race condition in that an oplock could
	 * have been broken due to another udp request, and yet there are
	 * still oplock break messages being sent in the udp message
	 * queue for this file. So return true if we don't have an oplock,
	 * as we may have just freed it.
	 */

	if(fsp->oplock_type == NO_OPLOCK) {
		DEBUG(3, ("initial_break_processing: file %s (file_id = %s "
			  "gen_id = %lu) has no oplock. Allowing break to "
			  "succeed regardless.\n", fsp_str_dbg(fsp),
			  file_id_string_tos(&id), fsp->fh->gen_id));
		return NULL;
	}

	return fsp;
}