www.pudn.com > efs.rar > fs_lib.h



/***********************************************************************
 * fs_lib.h
 *
 * Library API for EFS2.
 * Copyright (C) 2002-2006, Qualcomm, Inc.
 *
 ***********************************************************************/

 /*===========================================================================

                        EDIT HISTORY FOR MODULE

  This section contains comments describing changes made to the module.
  Notice that changes are listed in reverse chronological order.

  $Header: //depot/asic/MSMSHARED/services/efs/MSM_EFS.01.02/fs_lib.h#6 $ $DateTime: 2006/10/12 11:33:52 $ $Author: davidb $

when          who     what, where, why
--------      ---     ------------------------------------------------------
2006-09-25    umr     Added efs_deltree() for deleting a whole tree.
2005-11-12     sh     Use rex tcb err_num instead of global efs_errno
2005-10-28    nrs     Changed length fields from int to fs_size_t
2005-08-16    dlb     Update comments for put.
2005-02-15    nrs     Changed header for efs_put to reflect implementation
2004-10-28    nrs     Add efs_put_mkdir for autocreation of directories
2004-09-20    nrs     Created.

===========================================================================*/

#ifndef __FS_LIB_H__
#define __FS_LIB_H__

#include "fs_sys_types.h"
#include "fs_fcntl.h"

/**********************************************************************
 * Error handling.
 *
 * See fs_public.h
 *
 */

/**********************************************************************
 * Pathnames.
 *
 * See fs_public.h
 *
 */

/**********************************************************************
 * Library  API.
 */

/**********************************************************************
 * efs_put
 *
 * Store a value in an EFS2 'special item' file.  Item files are a unique
 * file type (S_IFITM) that can hold a small amount of data
 * (FS_ITEM_MAX), possibly more efficiently than regular files.
 * This function differs slightly from efs_raw_put () in that files larger
 * than FS_ITEM_MAX can also be placed into the filesystem. This
 * function will determine the type of file needed based on the length
 * parameter.  'efs_put' can also automatically create needed parent
 * directories, if O_AUTODIR is set.
 *
 * 'oflag' should be a bitwise OR of one of the following:
 *   O_CREAT   - Create the item if it does not exist.
 *   O_EXCL    - Fail if the item already exists.
 *   O_AUTODIR - Auto create parent directories.
 * other flags (O_APPEND, O_TRUNC) will have no effect.
 *
 * 'mode' will set the initial permission bits of the item file.
 *
 * Returns a zero if the item is written successfully, or -1 for error.  Upon
 * error, efs_errno will be set to one of the following:
 *   ENOENT - a directory component of 'path' does not exist.
 *   EEXIST - The entry already exists and O_EXCL was specified, or
 *            The entry exists and is not already an item.
 *   ELOOP  - A symlink named in 'path' contains a loop.
 *   ENAMETOOLONG - The 'path' specified, or a component of it is too long.
 *   FS_ERANGE - 'length' is larger than FS_ITEM_MAX.
 */
int efs_put (const char *path, void *data, fs_size_t length,
    int oflag, int mode);

/**********************************************************************
 * efs_get
 *
 * Retrieve an EFS2 'special item' file.  See 'efs_put' for a description
 * of these files.
 *
 * 'data' should be a pointer to a buffer, and 'length' should be the
 * number of bytes available in this buffer.  Returns the number of bytes
 * returned in the item file, or -1 for an error.  Upon error, efs_errno
 * will be set to one of the following:
 *   ENOENT - The item or a component of the path does not exist.
 *   ENOTITM - The named file is not of type S_IFITM.
 *   FS_ERANGE - The item file is larger than the specified buffer.
 */
int efs_get (const char *path, void *data, fs_size_t length);

/**********************************************************************
 * efs_deltree
 *
 * Delete the directory and all its contents. 'path' can be a directory
 * file, node or sym link. If a non directory is passed as argument it is
 * simply deleted. If the argument is a directory all its contents along
 * with itself is deleted. Returns 0 on success and -1 on failure. If a failure
 * occurs, the tree is only partially deleted. On a failure it is unknown as
 * to how many files or directories are left in the parent directory.
 */
int
efs_deltree (const char *path);

#endif /* End of __FS_LIB_H__ */