Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

Block class
[Linux 2.6 support]

Block class. More...

Data Structures

struct  mount_point_s
 Structure for holding mount point information. More...


Defines

#define MOUNT_POINT_MAX   256
#define MOUNT_POINT_STRING_SIZE   128

Functions

char * block_compute_udi (HalDevice *d, int append_num)
 This function will compute the device uid based on other properties of the device.

void visit_class_device_block_got_parent (HalDevice *parent, void *data1, void *data2)
 Callback when the parent is found or if there is no parent..

void visit_class_device_block (const char *path, struct sysfs_class_device *class_device)
 Visitor function for block device.

void linux_class_block_check_if_ready_to_add (HalDevice *d)
 Check if all the required properties are in place so we can announce this device to the world.

void etc_mtab_process_line (char *s)
 Process a line in /etc/mtab.

dbus_bool_t read_etc_mtab (dbus_bool_t force)
 Reads /etc/mtab and fill out mount_points and num_mount_points variables accordingly.

void sigio_handler (int sig)
 Signal handler for watching /etc.

void etc_mtab_process_all_block_devices (dbus_bool_t force)
 Load /etc/mtab and process all HAL block devices and set properties according to mount status.

void linux_class_block_init ()
 Init function for block device handling.

void force_unmount (HalDevice *d)
 Force unmount of a patition.

void force_unmount_of_all_childs (HalDevice *d)
 Unmount all partitions that stems from this block device.

void linux_class_block_removed (HalDevice *d)
 Called when this device is about to be removed.

dbus_bool_t detect_media (HalDevice *d)
 Check for media on a block device that is not a volume.

gboolean media_detect_timer_handler (gpointer data)
 Timeout handler for polling for media on block devices.

void linux_class_block_detection_done ()
 This function is called when all device detection on startup is done in order to perform optional batch processing on devices.

void linux_class_block_shutdown ()
 Shutdown function for block device handling.


Variables

mount_point_s mount_points [MOUNT_POINT_MAX]
 Array holding (valid) mount points from /etc/mtab.

int num_mount_points
 Number of elements in mount_points array.

int etc_fd = -1
time_t etc_mtab_mtime = 0
 Last mtime when /etc/mtab was processed.

dbus_bool_t have_setup_watcher = FALSE
 Global to see if we have setup the watcher on /etc.

dbus_bool_t sigio_etc_changed = FALSE
 Will be set to true by the SIGIO handler.


Detailed Description

Block class.


Function Documentation

char* block_compute_udi HalDevice d,
int  append_num
[static]
 

This function will compute the device uid based on other properties of the device.

For block device it's simply block appended with the major and minor number

Parameters:
d HalDevice object
append_num Number to append to name if not -1
Returns:
New unique device id; only good until the next invocation of this function

Definition at line 77 of file linux_class_block.c.

References ds_property_get_int(), and HalDevice.

Referenced by visit_class_device_block_got_parent().

dbus_bool_t detect_media HalDevice d  )  [static]
 

Check for media on a block device that is not a volume.

Parameters:
d Device to inspect; can be any device, but it will only have effect if the device is in the GDL and is of capability block and is not a volume
TRUE iff the GDL was modified

Definition at line 1099 of file linux_class_block.c.

References ds_device_destroy(), ds_device_find_by_key_value_string(), ds_device_merge(), ds_device_new(), ds_device_set_udi(), ds_gdl_add(), ds_property_exists(), ds_property_get_bool(), ds_property_get_string(), ds_property_set_bool(), ds_property_set_string(), force_unmount_of_all_childs(), HalDevice, HalDevice_s::in_gdl, and HalDevice_s::udi.

Referenced by linux_class_block_check_if_ready_to_add(), and media_detect_timer_handler().

void etc_mtab_process_all_block_devices dbus_bool_t  force  )  [static]
 

Load /etc/mtab and process all HAL block devices and set properties according to mount status.

Also, optionally, sets up a watcher to do this whenever /etc/mtab changes

Parameters:
force Force reading of mtab

Definition at line 785 of file linux_class_block.c.

References ds_device_iter_begin(), ds_device_iter_get(), ds_device_iter_has_more(), ds_device_iter_next(), ds_property_get_bool(), ds_property_get_int(), ds_property_get_string(), ds_property_set_bool(), ds_property_set_string(), emit_condition(), HalDevice, HalDeviceIterator, have_setup_watcher, mount_points, num_mount_points, property_atomic_update_begin(), property_atomic_update_end(), read_etc_mtab(), sigio_handler(), and HalDevice_s::udi.

Referenced by linux_class_block_detection_done(), media_detect_timer_handler(), and visit_class_device_block_got_parent().

void etc_mtab_process_line char *  s  )  [static]
 

Process a line in /etc/mtab.

The given string will be modifed by this function.

Parameters:
s Line of /etc/mtab

Todo:
FIXME: Use a linked list or something that doesn't restrict us like this

Definition at line 628 of file linux_class_block.c.

References mount_points, and num_mount_points.

Referenced by read_etc_mtab().

void force_unmount HalDevice d  )  [static]
 

Force unmount of a patition.

Must have block.volume=1 and valid block.device

Parameters:
d Device

Definition at line 937 of file linux_class_block.c.

References ds_property_exists(), ds_property_get_bool(), ds_property_get_string(), ds_property_set_bool(), ds_property_set_string(), emit_condition(), HalDevice, property_atomic_update_begin(), and property_atomic_update_end().

Referenced by force_unmount_of_all_childs(), and linux_class_block_removed().

void force_unmount_of_all_childs HalDevice d  )  [static]
 

Unmount all partitions that stems from this block device.

Must have block.is_volume==0

Parameters:
d Device

Definition at line 1016 of file linux_class_block.c.

References ds_device_find_multiple_by_key_value_string(), ds_property_get_string(), emit_condition(), force_unmount(), HalDevice, and HalDevice_s::udi.

Referenced by detect_media(), and linux_class_block_removed().

void linux_class_block_check_if_ready_to_add HalDevice d  ) 
 

Check if all the required properties are in place so we can announce this device to the world.

Parameters:
d Device

Definition at line 469 of file linux_class_block.c.

References detect_media(), ds_add_capability(), ds_gdl_add(), ds_property_get_bool(), ds_property_get_string(), ds_property_set_bool(), ds_property_set_int(), ds_property_set_string(), HalDevice, and HalDevice_s::udi.

Referenced by handle_udev_node_created_found_device(), and visit_class_device_block_got_parent().

void linux_class_block_removed HalDevice d  ) 
 

Called when this device is about to be removed.

Parameters:
d Device

Definition at line 1076 of file linux_class_block.c.

References ds_property_exists(), ds_property_get_bool(), force_unmount(), force_unmount_of_all_childs(), and HalDevice.

Referenced by handle_hotplug().

gboolean media_detect_timer_handler gpointer  data  )  [static]
 

Timeout handler for polling for media on block devices.

Parameters:
data User data when setting up timer
Returns:
TRUE iff timer should be kept

Todo:
FIXME GDL was modifed so we have to break here because we are iterating over devices and this will break it

Definition at line 1260 of file linux_class_block.c.

References detect_media(), ds_device_iter_begin(), ds_device_iter_get(), ds_device_iter_has_more(), ds_device_iter_next(), etc_mtab_process_all_block_devices(), HalDevice, HalDeviceIterator, and sigio_etc_changed.

Referenced by linux_class_block_detection_done().

dbus_bool_t read_etc_mtab dbus_bool_t  force  )  [static]
 

Reads /etc/mtab and fill out mount_points and num_mount_points variables accordingly.

This function holds the file open for further access

Parameters:
force Force reading of mtab
Returns:
FALSE if there was no changes to /etc/mtab since last invocation or an error occured

Definition at line 718 of file linux_class_block.c.

References etc_mtab_mtime, etc_mtab_process_line(), and num_mount_points.

Referenced by etc_mtab_process_all_block_devices().

void sigio_handler int  sig  )  [static]
 

Signal handler for watching /etc.

Parameters:
sig Signal number

Definition at line 915 of file linux_class_block.c.

References sigio_etc_changed.

Referenced by etc_mtab_process_all_block_devices().

void visit_class_device_block const char *  path,
struct sysfs_class_device *  class_device
 

Visitor function for block device.

This function parses the attributes present and creates a new HAL device based on this information.

Parameters:
path Sysfs-path for device
device libsysfs object for device

Todo:
FIXME is a block always 512 bytes?? Must check kernel source

Definition at line 107 of file linux_class_block.c.

References ds_add_capability(), ds_device_async_find_by_key_value_string(), ds_device_new(), ds_property_set_bool(), ds_property_set_int(), ds_property_set_string(), get_parent_sysfs_path(), HAL_LINUX_HOTPLUG_TIMEOUT, HalDevice, is_probing, parse_dec(), and visit_class_device_block_got_parent().

Referenced by visit_class_device().

void visit_class_device_block_got_parent HalDevice parent,
void *  data1,
void *  data2
[static]
 

Callback when the parent is found or if there is no parent..

This is where we get added to the GDL..

Parameters:
parent Async Return value from the find call
data1 User data
data2 User data

Todo:
FIXME free udev_stdout, udev_stderr?

Guestimate product name; use volume label

Given floppy how do we determine it's LS120?

block device on non-IDE device; how to find the name and the media-type? Right now we just assume that the disk is fixed and of type flash.. This hack does 'the right thing' on IDE-systems where the user attach a USB storage device.

We should special case for at least SCSI once this information is easily accessible in kernel 2.6.

Definition at line 217 of file linux_class_block.c.

References block_compute_udi(), ds_add_capability(), ds_device_destroy(), ds_device_find(), ds_property_exists(), ds_property_get_bool(), ds_property_get_string(), ds_property_set_bool(), ds_property_set_string(), etc_mtab_process_all_block_devices(), find_and_set_physical_device(), get_last_element(), HalDevice, HalDevice_s::in_gdl, is_probing, linux_class_block_check_if_ready_to_add(), read_single_line(), rename_and_merge(), sysfs_mount_path, and HalDevice_s::udi.

Referenced by visit_class_device_block().


Generated on Sat Feb 7 22:11:50 2004 for HAL by doxygen 1.3.5