Beispiel #1
0
/* mergeable_cde(): implementation of ->mergeable() item method.

   Two directory items are mergeable iff they are from the same
   directory. That simple.

*/
int mergeable_cde(const coord_t * p1 /* coord of first item */ ,
		  const coord_t * p2 /* coord of second item */ )
{
	reiser4_key k1;
	reiser4_key k2;

	assert("nikita-1339", p1 != NULL);
	assert("nikita-1340", p2 != NULL);

	return
	    (item_plugin_by_coord(p1) == item_plugin_by_coord(p2)) &&
	    (extract_dir_id_from_key(item_key_by_coord(p1, &k1)) ==
	     extract_dir_id_from_key(item_key_by_coord(p2, &k2)));

}
Beispiel #2
0
/* ->max_key_inside() method for this item plugin. */
reiser4_key *max_key_inside_cde(const coord_t * coord /* coord of item */ ,
				reiser4_key * result /* resulting key */ )
{
	assert("nikita-1342", coord != NULL);

	item_key_by_coord(coord, result);
	set_key_ordering(result, get_key_ordering(reiser4_max_key()));
	set_key_fulloid(result, get_key_fulloid(reiser4_max_key()));
	set_key_offset(result, get_key_offset(reiser4_max_key()));
	return result;
}
Beispiel #3
0
/* ->unit_key() method for this item plugin. */
reiser4_key *unit_key_cde(const coord_t * coord /* coord of item */ ,
			  reiser4_key * key /* resulting key */ )
{
	assert("nikita-1452", coord != NULL);
	assert("nikita-1345", idx_of(coord) < units(coord));
	assert("nikita-1346", key != NULL);

	item_key_by_coord(coord, key);
	extract_key_from_de_id(extract_dir_id_from_key(key),
			       &header_at(coord, idx_of(coord))->hash, key);
	return key;
}
Beispiel #4
0
/* return key of unit at @coord */
reiser4_key *unit_key_by_coord(const coord_t * coord /* coord to query */ ,
			       reiser4_key * key /* result */ )
{
	assert("nikita-772", coord != NULL);
	assert("nikita-774", coord->node != NULL);
	assert("nikita-775", znode_is_loaded(coord->node));

	if (item_plugin_by_coord(coord)->b.unit_key != NULL)
		return item_plugin_by_coord(coord)->b.unit_key(coord, key);
	else
		return item_key_by_coord(coord, key);
}
Beispiel #5
0
/* cde_check ->check() method for compressed directory items

   used for debugging, every item should have here the most complete
   possible check of the consistency of the item that the inventor can
   construct
*/
int reiser4_check_cde(const coord_t * coord /* coord of item to check */,
		      const char **error /* where to store error message */)
{
	int i;
	int result;
	char *item_start;
	char *item_end;
	reiser4_key key;

	coord_t c;

	assert("nikita-1357", coord != NULL);
	assert("nikita-1358", error != NULL);

	if (!ergo(coord->item_pos != 0,
		  is_dot_key(item_key_by_coord(coord, &key)))) {
		*error = "CDE doesn't start with dot";
		return -1;
	}
	item_start = item_body_by_coord(coord);
	item_end = item_start + item_length_by_coord(coord);

	coord_dup(&c, coord);
	result = 0;
	for (i = 0; i < units(coord); ++i) {
		directory_entry_format *entry;

		if ((char *)(header_at(coord, i) + 1) >
		    item_end - units(coord) * sizeof *entry) {
			*error = "CDE header is out of bounds";
			result = -1;
			break;
		}
		entry = entry_at(coord, i);
		if ((char *)entry < item_start + sizeof(cde_item_format)) {
			*error = "CDE header is too low";
			result = -1;
			break;
		}
		if ((char *)(entry + 1) > item_end) {
			*error = "CDE header is too high";
			result = -1;
			break;
		}
	}

	return result;
}
Beispiel #6
0
/* @data contains data which are to be put into tree */
int can_contain_key_cde(const coord_t * coord /* coord of item */ ,
			const reiser4_key * key /* key to check */ ,
			const reiser4_item_data * data	/* parameters of new
							 * item/unit being
							 * created */ )
{
	reiser4_key item_key;

	/* FIXME-VS: do not rely on anything but iplug field of @data. Only
	   data->iplug is initialized */
	assert("vs-457", data && data->iplug);
/*	assert( "vs-553", data -> user == 0 );*/
	item_key_by_coord(coord, &item_key);

	return (item_plugin_by_coord(coord) == data->iplug) &&
	    (extract_dir_id_from_key(&item_key) ==
	     extract_dir_id_from_key(key));
}