Main Page | Modules | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

Volume Services


Detailed Description

This functions entirely thorugh callbacks, the only extern routine is prv_init_rpc


Data Structures

struct  _AlpVolumeSvcsFSinfo
 File System info block, AlpVolumesvcsFSinfo returns a GArray of these. More...
struct  _prv_slot
struct  _prv_fsinfo

Defines

#define ALP_STATUS_VOLUMESVCS_OK   ALP_STATUS_OK
 operation completed sucessfully
#define ALP_STATUS_VOLUMESVCS_INVALID_PARAMETER   ( ALP_CLASS_VOLUMESVCS | 0x01)
 bad input
#define ALP_STATUS_VOLUMESVCS_NOT_FOUND   ( ALP_CLASS_VOLUMESVCS | 0x02)
 target device or volume could not be found
#define ALP_STATUS_VOLUMESVCS_DEVICE_BUSY   ( ALP_CLASS_VOLUMESVCS | 0x03)
 target device or bindmount could not be unmounted as it is in active use
#define ALP_NOTIFY_EVENT_VOLUME_ADDED   "/alp/volumesvcs/volume_added"
 a card has been inserted and the volumes on it mounted
#define ALP_NOTIFY_EVENT_VOLUME_REMOVED   "/alp/volumesvcs/volume_removed"
 a card with mounted volumes has been removed
#define ALP_NOTIFY_EVENT_DEVICE_ADDED   "/alp/volumesvcs/device_added"
 a card has been inserted that is either blank or the file system on it ws not recognized
#define ALP_NOTIFY_EVENT_DEVICE_REMOVED   "/alp/volumesvcs/device_removed"
 a card was removed that did not contain mounted file systems
#define ALP_SYSTEM_SLOTS_PREFIX   "/system/slots/"
 the head of the tree for slot names
#define ALP_SYSTEM_SLOTS_NAME   "/name"
 the name to be used for this slot
#define ALP_SYSTEM_SLOTS_DEV_PATH   "/dev_path"
 the /dev/name to match against (may be incomplete /dev/mmcblk matches /dev/mmcblk0...)
#define ALP_VOLUMESVCS_HIDEVOL_PATH   ALP_EXT_SYSPATH_HIDDEN_VOL
 if this exists the volume is not exposed to users
#define ALP_VOLUMESVCS_FLAGS_BINDMOUNT   0x1
 entry represents a bind mount not necessarily a real device
#define ALP_VOLUMESVCS_FLAGS_PARTITION   0x2
 entry represents a partition with or witout fs as opposed to an entire disk (disk are only shown if there are no partitions on them).
#define ALP_VOLUMESVCS_FLAGS_HIDDEN   0x4
 entry represents an entry to be hidden from users
#define TRACELEVEL   0
#define MAX_TRACELEVEL   3
#define ALP_VSTL(level, str,)
#define MEMCHECK(p)   ALP_FAIL_FATAL_IF( p == NULL, "out of memory")
#define AisBsParent(a, b)   ( a->sys_dev_path && b->sys_dev_path && !strncmp(a->sys_dev_path, b->sys_dev_path, strlen(a->sys_dev_path)) )
#define MOUNTROOT   "/media"
#define MOUNT_OPTIONS   MS_NOATIME+MS_NODEV+MS_NOSUID+MS_SYNCHRONOUS
#define UMOUNT_OPTIONS   MNT_FORCE
#define NOTIFY_TIMEOUT   0
#define ACCESS_UDI_ROOT   "/access/ALP/volumesvcs/"
#define FAT_IOCTL_SET_VOLUME_LABEL   0x40047215
#define MSDOS_NAME   11
#define EVENT_TIMEOUT   2000

Typedefs

typedef char * AlpNotifyEventVolumeAdded
 notification detail for a volume added event
typedef char * AlpNotifyEventVolumeRemoved
 notification detail for a volume removed event
typedef char * AlpNotifyEventDeviceAdded
 notification detail for a device added event
typedef char * AlpNotifyEventdeviceRemoved
 notification detail for a device removed event
typedef _AlpVolumeSvcsFSinfo AlpVolumeSvcsFSinfo
 File System info block, AlpVolumesvcsFSinfo returns a GArray of these.
typedef _prv_slot prv_slot_t
typedef _prv_fsinfo prv_fsinfo_t

Functions

alp_status_t alp_volumesvcs_fsinfo_array (GArray **fsinfo_array)
 Get information on all pluggable devices and any mounted file systems on them.
alp_status_t alp_volumesvcs_fsinfo_for_udi (AlpVolumeSvcsFSinfo **fsinfo, const gchar *udi)
 Allocates and returns an AlpVolumeSvcsFSinfo* matching the _udi parameter passed in.
alp_status_t alp_volumesvcs_fsinfo_array_free (GArray *fsinfo_array)
 Free the array of AlpVolumeSvcsFSinfo struct's.
alp_status_t alp_volumesvcs_fsinfo_free (AlpVolumeSvcsFSinfo *fsinfo)
 Frees AlpVolumeSvcsFSinfo* allocated by alp_volumesvcs_fsinfo_for_udi().
alp_status_t alp_volumesvcs_mount (const gchar *device_udi)
 Mount a volume.
alp_status_t alp_volumesvcs_umount (const gchar *device_udi)
 UNmount a volume.
alp_status_t alp_volumesvcs_fstypes (GPtrArray **fstypes)
 return a list of filesystem types that may be used as input to alp_volumesvcs_makefs Other formats MAY be supported for mounting a pre-formated volume, but only these may be used to format a volume ON the ALP device.
alp_status_t alp_volumesvcs_makefs (const gchar *device_udi, const gchar *name, const gchar *fstype)
 Initialzie a volume, Create a 1 part partition table and make a msdos file system in it.
alp_status_t alp_volumesvcs_bind (const gchar *name, const gchar *path)
 Mount a directory as if it were a file system (bind mounts) This entry will be assgined a udi which may be looked up in fsinfo and explicitly umounted but the entry can not be removed until the volumesvcsd server is restarted.
alp_status_t alp_volumesvcs_rename_volume (const char *udi, const gchar *name)
 Reanme a volume. The volume name (part of the vfat format) is changed. The volume can be mounted or unmounted when the call is made. If mounted it will be UNmounted as part of the call. The renamed volume is always mounted on return from this call (barrying errors that prevent such).
alp_status_t alp_volumesvcs_bind (const gchar *name, const char *path)
 Mount a dir as if it was a device.
alp_status_t alp_volumesvcs_rename_volume (const gchar *udi, const char *name)
 rename a volume
bool prv_mount (prv_fsinfo_t *entry)
 mount a device entry turning it into a volume entry
bool prv_umount (prv_fsinfo_t *entry)
 umount a volume turning it back into a device, which usually was just ejected
bool prv_bind_mount (gchar *name, gchar *path)
bool prv_rename (prv_fsinfo_t *entry, const gchar *name)
bool prv_makefs (prv_fsinfo_t *entry, const gchar *name, const gchar *fstype)
void prv_dump (int level)
 dump out a trace of our current view of the mounted volumes & devices
void prv_device_add (prv_fsinfo_t *new_entry)
 addition of a device
void prv_device_remove (prv_fsinfo_t *entry)
 callback for the removal of a device
prv_fsinfo_tprv_entry_match (const gchar *udi, bool allocate)
 see if we have an existing entry that matches the passed udi
void prv_init_rpc ()
bool prv_rename (prv_fsinfo_t *entry, gchar *name)
 rename a volume
void prv_empty_entry (prv_fsinfo_t *entry)
 , free the contents of an entry
void prv_entry_remove (prv_fsinfo_t *entry)
 remove an entry from the internal table,
gboolean prv_timeout_cb (gpointer flag)
int main (int argc, char **argv)

Variables

int gtracelevel
GArray * gfsinfo
GArray * gslots
GPtrArray * gfstypes
int gtracelevel = TRACELEVEL
GArray * gfsinfo
GPtrArray * gfstypes
GArray * gslots


Define Documentation

#define ACCESS_UDI_ROOT   "/access/ALP/volumesvcs/"
 

#define AisBsParent a,
 )     ( a->sys_dev_path && b->sys_dev_path && !strncmp(a->sys_dev_path, b->sys_dev_path, strlen(a->sys_dev_path)) )
 

#define ALP_NOTIFY_EVENT_DEVICE_ADDED   "/alp/volumesvcs/device_added"
 

a card has been inserted that is either blank or the file system on it ws not recognized

#define ALP_NOTIFY_EVENT_DEVICE_REMOVED   "/alp/volumesvcs/device_removed"
 

a card was removed that did not contain mounted file systems

#define ALP_NOTIFY_EVENT_VOLUME_ADDED   "/alp/volumesvcs/volume_added"
 

a card has been inserted and the volumes on it mounted

Remarks:
Alp Notification events are just strings representing each event type the following notifications are broadcast with ALP_NOTIFY_PRIORITY_NORMAL ALP_NOTIFY_QUEUE_DEFAULT

#define ALP_NOTIFY_EVENT_VOLUME_REMOVED   "/alp/volumesvcs/volume_removed"
 

a card with mounted volumes has been removed

#define ALP_STATUS_VOLUMESVCS_DEVICE_BUSY   ( ALP_CLASS_VOLUMESVCS | 0x03)
 

target device or bindmount could not be unmounted as it is in active use

#define ALP_STATUS_VOLUMESVCS_INVALID_PARAMETER   ( ALP_CLASS_VOLUMESVCS | 0x01)
 

bad input

#define ALP_STATUS_VOLUMESVCS_NOT_FOUND   ( ALP_CLASS_VOLUMESVCS | 0x02)
 

target device or volume could not be found

#define ALP_STATUS_VOLUMESVCS_OK   ALP_STATUS_OK
 

operation completed sucessfully

#define ALP_SYSTEM_SLOTS_DEV_PATH   "/dev_path"
 

the /dev/name to match against (may be incomplete /dev/mmcblk matches /dev/mmcblk0...)

#define ALP_SYSTEM_SLOTS_NAME   "/name"
 

the name to be used for this slot

#define ALP_SYSTEM_SLOTS_PREFIX   "/system/slots/"
 

the head of the tree for slot names

Remarks:
global settings names, setup by the device vendor to name the media slots on the device e.g. /system/slots/0/name = "Expansion Card" /system/slots/0/hal_key = "info.parent" /system/slots/0/hal_value = "/org/freedesktop/Hal/devices/platform_pxa2xx_mci_mmc_card_rca1" Which would cause all cards with the specifed parent to get a name of "Expansion Card"

#define ALP_VOLUMESVCS_FLAGS_BINDMOUNT   0x1
 

entry represents a bind mount not necessarily a real device

#define ALP_VOLUMESVCS_FLAGS_HIDDEN   0x4
 

entry represents an entry to be hidden from users

#define ALP_VOLUMESVCS_FLAGS_PARTITION   0x2
 

entry represents a partition with or witout fs as opposed to an entire disk (disk are only shown if there are no partitions on them).

#define ALP_VOLUMESVCS_HIDEVOL_PATH   ALP_EXT_SYSPATH_HIDDEN_VOL
 

if this exists the volume is not exposed to users

#define ALP_VSTL level,
str   ) 
 

Value:

if (level <= gtracelevel)  \
                ALP_TM(TL(ALP_CLASS_VOLUMESVCS, "%s():@%d " str, __PRETTY_FUNCTION__,time(NULL), ## __VA_ARGS__))

#define EVENT_TIMEOUT   2000
 

#define FAT_IOCTL_SET_VOLUME_LABEL   0x40047215
 

#define MAX_TRACELEVEL   3
 

#define MEMCHECK  )     ALP_FAIL_FATAL_IF( p == NULL, "out of memory")
 

#define MOUNT_OPTIONS   MS_NOATIME+MS_NODEV+MS_NOSUID+MS_SYNCHRONOUS
 

#define MOUNTROOT   "/media"
 

#define MSDOS_NAME   11
 

#define NOTIFY_TIMEOUT   0
 

#define TRACELEVEL   0
 

#define UMOUNT_OPTIONS   MNT_FORCE
 


Typedef Documentation

typedef char* AlpNotifyEventDeviceAdded
 

notification detail for a device added event

typedef char* AlpNotifyEventdeviceRemoved
 

notification detail for a device removed event

typedef char* AlpNotifyEventVolumeAdded
 

notification detail for a volume added event

Remarks:
The detail argument for Alp notifications for volume services are simply the character strings that are the UDI for the event in question (found in the udi filed of an AlpVolumesvcsFSinfo struct). These typedefs are just for convienence.

typedef char* AlpNotifyEventVolumeRemoved
 

notification detail for a volume removed event

typedef struct _AlpVolumeSvcsFSinfo AlpVolumeSvcsFSinfo
 

File System info block, AlpVolumesvcsFSinfo returns a GArray of these.

typedef struct _prv_fsinfo prv_fsinfo_t
 

typedef struct _prv_slot prv_slot_t
 


Function Documentation

alp_status_t alp_volumesvcs_bind const gchar *  name,
const char *  path
 

Mount a dir as if it was a device.

Parameters:
[in] name - the mountpoint name under /media (will be created as usual)
[in] path - the path to the dir to mount
Returns:
- ALP_STATUS_OK mount succeeded (or is already mounted)

alp_status_t alp_volumesvcs_bind const gchar *  name,
const gchar *  path
 

Mount a directory as if it were a file system (bind mounts) This entry will be assgined a udi which may be looked up in fsinfo and explicitly umounted but the entry can not be removed until the volumesvcsd server is restarted.

Parameters:
[in] name - the user visible name (label) this device should have, this will be the default mount point under /media
[in] path - the directory to mount on /media/<name>
Returns:
ALP_STATUS_OK if a new fs was successfully written ALP_STATUS_VOLUMESVCS_NOT_FOUND if there is no match for the UDI. ALP_STATUS_VOLUMESVCS_INVALID_PARAMETER if the udi parameter is NULL.or the mount is not sucessful for any reason

alp_status_t alp_volumesvcs_fsinfo_array GArray **  fsinfo_array  ) 
 

Get information on all pluggable devices and any mounted file systems on them.

Parameters:
[in] fsinfo_array is a pointer to the GArray of AlpVolumeSvcsFSinfo structs returned a distinct call is needed here rather than g_array_free due to allowing freeing of the embeded structures not just the array elements and the array itself.
Returns:
- ALP_STATUS_OK, an GArray was returned (*fsinfo_array->length might == 0)

alp_status_t alp_volumesvcs_fsinfo_array_free GArray *  fsinfo_array  ) 
 

Free the array of AlpVolumeSvcsFSinfo struct's.

Parameters:
[in] fsinfo_array is a pointer to the GArray returned on a alp_volumesvcs_fsinfo call a distinct call is needed here rather than g_array_free due to allowing freeing of the embeded structures not just the array elements and the array itself. Passing in NULL is ok
Returns:
- ALP_STATUS_OK in all cases (a bad pointer will result in the program aborting)

alp_status_t alp_volumesvcs_fsinfo_for_udi AlpVolumeSvcsFSinfo **  info,
const gchar *  udi
 

Allocates and returns an AlpVolumeSvcsFSinfo* matching the _udi parameter passed in.

Parameters:
[out] _info This will be allocated if the udi parameter matches a currently avilable volume, otherwise it will remain unchaged. This must be freed with alp_volumesvcs_fsinfo_free().
[in] udi The UDI to match for.
Returns:
ALP_STATUS_OK if the UDI is matched. ALP_STATUS_VOLUMESVCS_NOT_FOUND if there is no match for the UDI. ALP_STATUS_VOLUMESVCS_INVALID_PARAMETER if the udi parameter is NULL.

alp_status_t alp_volumesvcs_fsinfo_free AlpVolumeSvcsFSinfo info  ) 
 

Frees AlpVolumeSvcsFSinfo* allocated by alp_volumesvcs_fsinfo_for_udi().

Parameters:
[in] _info The pointer to free.
Returns:
ALP_STATUS_OK is always returned, even when _info is NULL.

alp_status_t alp_volumesvcs_fstypes GPtrArray **  fstypes  ) 
 

return a list of filesystem types that may be used as input to alp_volumesvcs_makefs Other formats MAY be supported for mounting a pre-formated volume, but only these may be used to format a volume ON the ALP device.

Parameters:
[in] fstypes - address of a pointer to a GPtrArray
Returns:
- ALP_STATUS_OK in all cases
Remarks:
the returned array may be freed wtih g_ptr_array_free( fstypes, TRUE )

alp_status_t alp_volumesvcs_makefs const gchar *  udi,
const gchar *  name,
const gchar *  fstype
 

Initialzie a volume, Create a 1 part partition table and make a msdos file system in it.

Parameters:
[in] device_udi the hal UDI for the parent device (e.g. /dev/sdd) to format.
[in] name the user visible name (label) this device should have, this will be the default mount point under /media
[in] fstype (must be amonng the strings returned by alp_volumesvcs_fstypes, typically FAT16 or FAT32
Returns:
ALP_STATUS_OK if it was found and unmounted
Remarks:
Note there is no option to add a partition or have multiple partions, you just get a single partition table and a newfs in that single partition. Multiple partition devices are supported, but they must be formated elsewhere.

alp_status_t alp_volumesvcs_mount const gchar *  udi  ) 
 

Mount a volume.

Parameters:
[in] udi - refers to an entry in fsinfo to mount
Returns:
- ALP_STATUS_OK, the volume is mounted (might have already been mounted)

alp_status_t alp_volumesvcs_rename_volume const gchar *  udi,
const char *  name
 

rename a volume

Parameters:
[in] udi - the volume to rename
[in] name - what to rename it too
Returns:
- ALP_STATUS_OK mount succeeded (or is already mounted)

alp_status_t alp_volumesvcs_rename_volume const char *  udi,
const gchar *  name
 

Reanme a volume. The volume name (part of the vfat format) is changed. The volume can be mounted or unmounted when the call is made. If mounted it will be UNmounted as part of the call. The renamed volume is always mounted on return from this call (barrying errors that prevent such).

Parameters:
[in] udi - the volume to rename
[in] name - the new user visible name (label) this device should have, this will be the default mount point under /media
Returns:
ALP_STATUS_OK if a new fs was successfully written ALP_STATUS_VOLUMESVCS_NOT_FOUND if there is no match for the UDI. ALP_STATUS_VOLUMESVCS_INVALID_PARAMETER if the udi parameter is NULL. ALP_STATUS_VOLUMESVCS_IN_USE if the volume is mounted and for some reason can not be unmounted

alp_status_t alp_volumesvcs_umount const gchar *  udi  ) 
 

UNmount a volume.

Parameters:
[in] udi - entry in fsinfo to umount
Returns:
- ALP_STATUS_OK, the referenced volume is (or was) unmounted

int main int  argc,
char **  argv
 

main serer entry

bool prv_bind_mount gchar *  name,
gchar *  path
 

void prv_device_add prv_fsinfo_t new_entry  ) 
 

addition of a device

Parameters:
[in] entry - pointer to a partially filled in block but no udi
Returns:
- none

void prv_device_remove prv_fsinfo_t entry  ) 
 

callback for the removal of a device

Parameters:
[in] entry - pointer to entry to remove
Returns:
- none

void prv_dump int  level  ) 
 

dump out a trace of our current view of the mounted volumes & devices

Returns:
- none

void prv_empty_entry prv_fsinfo_t entry  ) 
 

, free the contents of an entry

Parameters:
[in] entry - pointer to entry to empty out
Returns:
- none

prv_fsinfo_t * prv_entry_match const gchar *  udi,
bool  allocate
 

see if we have an existing entry that matches the passed udi

Parameters:
[in] udi - udi to match against
[in] allocate - if true allocate an entry if no match is found
Returns:
- pointer to matching prv_fsinfo_t entry or NULL

void prv_entry_remove prv_fsinfo_t entry  ) 
 

remove an entry from the internal table,

Parameters:
[in] entry - pointer to entry to remove
Returns:
- none

void prv_init_rpc  ) 
 

bool prv_makefs prv_fsinfo_t entry,
const gchar *  name,
const gchar *  fstype
 

partiiton and create a file system on this device, using the entire device No provisions are made for creating multiple partitions or using one that already exists.

Parameters:
[in] entry - pointer to the thing to makefs on, might a volume or a device e.g. /dev/mmcblk0p1 or /dev/mmcblk0
[in] name - the label for the volume
[in] fstype - currently either fat32 or fat16 (case insensitive)
Returns:
- TRUE it all worked, FALSE it didn't
beware that the commands executed here will both casue udev events and thus to get those callbacks we have to let the glib main loop run and anytime that happens we assume the gfsinfo array might have changed

bool prv_mount prv_fsinfo_t entry  ) 
 

mount a device entry turning it into a volume entry

Parameters:
[in] entry - prv_fsinfo_t for the target device/volume
Returns:
- success or failure of mount

bool prv_rename prv_fsinfo_t entry,
gchar *  name
 

rename a volume

Parameters:
[in] entry - prv_fsinfo_t for the target device/volume
[in] name - what to rename it too
Returns:
- success or failure of mount

bool prv_rename prv_fsinfo_t entry,
const gchar *  name
 

gboolean prv_timeout_cb gpointer  flag  ) 
 

bool prv_umount prv_fsinfo_t entry  ) 
 

umount a volume turning it back into a device, which usually was just ejected

Parameters:
[in] entry - the volume
Returns:
- none, always success


Variable Documentation

GArray* gfsinfo
 

GArray* gfsinfo
 

GPtrArray* gfstypes
 

GPtrArray* gfstypes
 

GArray* gslots
 

GArray* gslots
 

int gtracelevel = TRACELEVEL
 

int gtracelevel
 


Generated on Sat Dec 16 20:29:50 2006 for hiker-0.9 by  doxygen 1.4.4