Esempio n. 1
0
END_TEST

START_TEST(test_setOwner)
{
	bool s;
	struct hdfs_object *e = NULL;
	const char *tf = "/HADOOFUS_TEST_SETOWNER",
	      *client = "HADOOFUS_CLIENT";

	// Create the file first
	hdfs_create(h, tf, 0644, client, true/*overwrite*/,
	    false/*createparent*/, 1/*replication*/, 64*1024*1024, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	hdfs_setOwner(h, tf, "daemon", "wheel", &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	// Cleanup
	s = hdfs_delete(h, tf, false/*recurse*/, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert_msg(s, "delete returned false");
}
Esempio n. 2
0
/**
 * hdfsChown
 *
 * @param fs The configured filesystem handle.
 * @param path the path to the file or directory
 * @param owner this is a string in Hadoop land. Set to null or "" if only setting group
 * @param group  this is a string in Hadoop land. Set to null or "" if only setting user
 * @return 0 on success else -1
 */
int
hdfsChown(hdfsFS fs, const char* path, const char *owner, const char *group)
{
	int res = 0;
	struct hdfsFS_internal *client = fs;
	struct hdfs_object *ex = NULL;
	char *path_abs = _makeabs(fs, path);

	hdfs_setOwner(client->fs_namenode, path_abs, owner, group, &ex);
	if (ex) {
		ERR(EIO, "setOwner(): %s", hdfs_exception_get_message(ex));
		res = -1;
		goto out;
	}

out:
	if (ex)
		hdfs_object_free(ex);
	if (path_abs != path)
		free(path_abs);
	return res;
}