Commit 0ee59e12 authored by Surbhi Palande's avatar Surbhi Palande
Browse files

Changed the interface to stop/restart timers to use a mountpoint rather than

the device name. This is useful in situations where the device mentioned in
/etc/fstab is not the device used for mounting because of the change mount
device interface. The mountpoint remains constant in all cases and is also
easier to use that specifying a device with uuids for eg.
parent 117aa11b
......@@ -22,11 +22,11 @@
<!-- Get object paths for jobs, while you can figure them out, it's
better form to use these -->
<method name="StopTimer">
<arg name="devname" type="s" direction="in" />
<arg name="mountpoint" type="s" direction="in" />
</method>
<method name="RestartTimer">
<arg name="devname" type="s" direction="in" />
<arg name="mountpoint" type="s" direction="in" />
</method>
<method name="ChangeMountDevice">
......
......@@ -149,57 +149,59 @@ control_disconnected (DBusConnection *conn)
/**
* control_stop_timer:
* @devname: Name of the device whose timer you want to stop.
* @mountpoint: the mountpoint corresponding to the device for which the
* timeout option has to be disabled.
*
* Implements the StopTimer method of com.ubuntu.Moutall01_Server
* interface.
*
* This function is called for stopping a previously started timer for a
* @device. Stopping a timer has the effect that mountall would no longer
* expect the device to be ready within a previously registered stipulated
* time period. After this call, mountall will wait endlessly till the device
* becomes ready! Use this function only when you know that you might restart
* the timer later or that you really want to wait endlessly for the device to
* become available.
* mountpoint. Stopping a timer has the effect that mountall would no longer
* expect the corresponding device to be ready within a previously registered
* stiplulated time period. After this call, mountall will wait endlessly till
* the device becomes ready. Use this function only when you know that you
* might restart the timer later or that you really want to wait endlessly
* till the device becomes available.
*
* Returns 0 on success and -1 on failure.
**/
int
control_stop_timer (void *data,
NihDBusMessage *message,
const char *devname)
const char *mountpoint)
{
nih_assert (devname != NULL);
nih_assert (mountpoint != NULL);
nih_assert (message != NULL);
return stop_dev_timer (devname);
return stop_dev_timer (mountpoint);
}
/**
* control_restart_timer:
* @devname: Name of the device whose timer you want to stop.
* @mountpoint: the mountpoint corresponding to the device for which the
* timeout option has to be disabled.
*
* Implements the RestartTimer method of com.ubuntu.Moutall01_Server
* interface.
*
* This function is called for restarting a previously stopped timer for a
* @device. After successfully restarting a timer, mountall will expect the
* device to become ready for mounting within the previously configured
* timeout or the default of 30 seconds.
* mountpoint. After successfully restarting a timer, mountall will expect the
* corresponding device to become ready for mounting within the previously
* configured timeout or the default of 30 seconds.
*
* Returns 0 on success and -1 on failure.
**/
int
control_restart_timer (void *data,
NihDBusMessage *message,
const char *devname)
const char *mountpoint)
{
nih_assert (devname != NULL);
nih_assert (mountpoint != NULL);
nih_assert (message != NULL);
return restart_dev_timer (devname);
return restart_dev_timer (mountpoint);
}
/**
......
......@@ -23,10 +23,10 @@ extern const NihDBusInterface *control_interfaces[];
int control_server_open (void);
int control_stop_timer (void *data, NihDBusMessage *message,
const char *devname)
const char *mountpoint)
__attribute__ ((warn_unused_result));
int control_restart_timer (void *data, NihDBusMessage *message,
const char *devname)
const char *mountpoint)
__attribute__ ((warn_unused_result));
int control_change_mount_device (void *data, NihDBusMessage *message,
const char *devname, const char *path)
......@@ -34,6 +34,3 @@ int control_change_mount_device (void *data, NihDBusMessage *message,
int control_get_version (void *data, NihDBusMessage *message,
char **value)
__attribute__ ((warn_unused_result));
int control_get_mount_devices (void *data, NihDBusMessage *message,
char ***devs, char ***mntpoints)
__attribute__ ((warn_unused_result));
......@@ -3390,26 +3390,28 @@ set_dev_wait_time (NihOption *option,
return err;
}
/**
* stop_dev_timer:
* @devname: Name of the device whose timer you want to stop.
* stop_mountpoint_timer:
* @mountpoint: mountpoint whose timer you want to stop.
*
* This function is called to stop a previously started timer of a device.
* Note that for this function to be successful, @devname should be a device
* that mountall found with the "timeout" option enabled in the fstab.
* This function is called to stop a previously started timer of a device
* Note that for this function to be successful, @mountpoint should be a
* mountpoint corresponding to a device whose "timeout" option is set in the
* /etc/fstab.
*
* Returns 0 on stopping the timer and -1 on not doing so.
*
**/
int
stop_dev_timer (const char *devname)
stop_dev_timer (const char *mountpoint)
{
int ret = -1;
nih_assert (devname != NULL);
nih_assert (mountpoint != NULL);
if (strlen (devname) == 0) {
nih_message (_("Empty device name specified"));
if (strlen (mountpoint) == 0) {
nih_message (_("Empty mountpoint specified"));
return ret;
}
......@@ -3427,7 +3429,7 @@ stop_dev_timer (const char *devname)
&& ((! strncmp (mnt->device, "/dev/", 5))
|| (! strncmp (mnt->device, "UUID=", 5))
|| (! strncmp (mnt->device, "LABEL=", 6)))
&& (! strcmp (mnt->device, devname)))
&& (! strcmp (mnt->mountpoint, mountpoint)))
{
if (device_ready_timer) {
nih_debug ("Stopping the timer for the device:"
......@@ -3441,30 +3443,30 @@ stop_dev_timer (const char *devname)
}
}
nih_message (_("stop_dev_timer returning: %d"), ret);
return ret;
}
/**
* restart_dev_timer:
* @devname: Name of the device whose timer you want to restart.
** @mountpoint: mountpoint whose timer you want to stop.
*
* This function is called to restart a previously stopped timer of a device.
* Note that for this function to be successful, @devname should be a device
* that mountall found with the "timeout" option enabled in the fstab.
* This function is called to restart a previously stopped timer of a device
* Note that for this function to be successful, @mountpoint should be a
* mountpoint corresponding to a device whose "timeout" option is set in the
* /etc/fstab.
*
* Returns 0 on restarting the timer and -1 on not doing so.
*
**/
int
restart_dev_timer (const char *devname)
restart_dev_timer (const char *mountpoint)
{
int ret = -1;
nih_assert (devname != NULL);
nih_assert (mountpoint != NULL);
if (strlen (devname) == 0) {
nih_message (_("Empty device name specified"));
if (strlen (mountpoint) == 0) {
nih_message (_("Empty mountpoint specified"));
return ret;
}
......@@ -3482,7 +3484,7 @@ restart_dev_timer (const char *devname)
&& ((! strncmp (mnt->device, "/dev/", 5))
|| (! strncmp (mnt->device, "UUID=", 5))
|| (! strncmp (mnt->device, "LABEL=", 6)))
&& (! strcmp (mnt->device, devname)))
&& (! strcmp (mnt->mountpoint, mountpoint)))
{
if (!dev_wait_time)
......@@ -3499,7 +3501,6 @@ restart_dev_timer (const char *devname)
}
}
nih_message (_("restart_dev_timer returns: %d"), ret);
return ret;
}
......
......@@ -16,11 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
int stop_dev_timer (const char * devname)
int stop_dev_timer (const char * mountpoint)
__attribute__ ((warn_unused_result));
int restart_dev_timer (const char * devname)
int restart_dev_timer (const char * mountpoint)
__attribute__ ((warn_unused_result));
int change_mount_device (const char * devname, const char * path)
__attribute__ ((warn_unused_result));
int get_mount_devices (NihDBusMessage *message, char *** devs, char *** mntpoints)
__attribute__ ((warn_unused_result));
......@@ -340,17 +340,17 @@ static NihCommandGroup mount_commands = { N_("Mounts") };
* Commands accepts as the first non-option argument, or program name.
**/
static NihCommand commands[] = {
{ "stop-timer", N_("DEVICE-NAME"),
{ "stop-timer", N_("MOUNTPOINT"),
N_("Stop a timer associated with the specified device"),
N_("DEVICE-NAME is the name of the device whose timer you want to "
"stop so that it can become ready whenever possible"),
N_("MOUNTPOINT is the mountpoint corresponding to a device whose "
"timer you want to stop"),
&timer_commands, stop_timer_options, stop_timer_action },
{ "restart-timer", N_("DEVICE-NAME"),
{ "restart-timer", N_("MOUNTPOINT"),
N_("Restart a timer associated with the specified device"),
N_("DEVICE-NAME is the name of the device which should become "
"ready within the default wait time or the time specified "
"explicitly as a command line argument to mountall") ,
N_("MOUNTPOINT is the mountpoint corresponding to a device that "
"should become ready withing the default wait time or the time "
"specified explicitly as a command line argument to mountall") ,
&timer_commands, restart_timer_options, restart_timer_action },
{ "change-mount", N_("DEVICE-NAME PATH"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment