Example #1
0
/**
 * get object information
 *
 * \param[in] obj the object to be revealed
 * \param[out] info object information will be loaded to info
 * \param[out] err return error code if failed
 *
 * \return U_SUCC or U_FAIL
 *
 * \node the obj should be openned before call this function.
 */
URET uffs_GetObjectInfo(uffs_Object *obj, uffs_ObjectInfo *info, int *err)
{
	uffs_Device *dev = obj->dev;
	URET ret = U_FAIL;

	uffs_DeviceLock(dev);

	if (obj && dev && info) {
		if (obj->parent == PARENT_OF_ROOT) {
			// this is ROOT. UFFS does not physically has root, just fake it ...
			memset(info, 0, sizeof(uffs_ObjectInfo));
			info->serial = obj->serial;
			info->info.attr |= (FILE_ATTR_DIR | FILE_ATTR_WRITE);
			if (err)
				*err = UENOERR;
			ret = U_SUCC;
		}
		else
			ret = _LoadObjectInfo(dev, obj->node, info, obj->type, err);
	}
	else {
		if (err)
			*err = UEINVAL;
	}

	uffs_DeviceUnLock(dev);

	return ret;
}
Example #2
0
File: uffs_fs.c Project: mazj/uffs
static void uffs_ObjectDevLock(uffs_Object *obj)
{
	if (obj) {
		if (obj->dev) {
			uffs_DeviceLock(obj->dev);
			obj->dev_lock_count++;
		}
	}
}
Example #3
0
/**
 * Find the first object
 *
 * \param[out] info the object information will be filled to info.
 *				if info is NULL, then skip this object.
 * \param[in] f uffs_FindInfo structure, openned by uffs_FindObjectOpen().
 *
 * \return U_SUCC if an object is found, U_FAIL if no object is found.
 */
URET uffs_FindObjectFirst(uffs_ObjectInfo * info, uffs_FindInfo * f)
{
	uffs_Device *dev = f->dev;
	URET ret = U_SUCC;

	uffs_DeviceLock(dev);
	ResetFindInfo(f);
	ret = do_FindObject(f, info, dev->tree.dir_entry[0]);
	uffs_DeviceUnLock(dev);

	return ret;
}
Example #4
0
/**
 * Find the next object.
 *
 * \param[out] info the object information will be filled to info.
 *				if info is NULL, then skip this object.
 * \param[in] f uffs_FindInfo structure, openned by uffs_FindObjectOpen().
 *
 * \return U_SUCC if an object is found, U_FAIL if no object is found.
 *
 * \note uffs_FindObjectFirst() should be called before uffs_FindObjectNext().
 */
URET uffs_FindObjectNext(uffs_ObjectInfo *info, uffs_FindInfo * f)
{
	uffs_Device *dev = f->dev;
	URET ret = U_SUCC;

	if (f->dev == NULL || f->step > 1) 
		return U_FAIL;

	if (f->work == NULL)
		return uffs_FindObjectFirst(info, f);

	uffs_DeviceLock(dev);
	ret = do_FindObject(f, info, f->work->hash_next);
	uffs_DeviceUnLock(dev);

	return ret;
}
Example #5
0
/**
 * get object information
 *
 * \param[in] obj the object to be revealed
 * \param[out] info object information will be loaded to info
 * \param[out] err return error code if failed
 *
 * \return U_SUCC or U_FAIL
 *
 * \node the obj should be openned before call this function.
 */
URET uffs_GetObjectInfo(uffs_Object *obj, uffs_ObjectInfo *info, int *err)
{
	uffs_Device *dev = obj->dev;
	URET ret = U_FAIL;

	uffs_DeviceLock(dev);

	if (obj && dev && info) {
		ret = _LoadObjectInfo(dev, obj->node, info, obj->type, err);
	}
	else {
		if (err)
			*err = UEINVAL;
	}

	uffs_DeviceUnLock(dev);

	return ret;
}