/* Functions for connecting to some services, which is needed for FS. */
/* Methods:
* common_connection: includes common aspects for connecting to some services
* con_connection: connects to SERVICE_CONSOLE
* rd_connection: connects to SERVICE_RD
* fs_connection: connects to SERVICE_FS
*
*/
#include <ipc/ipc.h>
#include <ipc/services.h>
#include "../fs/fs.h"
int common_connection(int *phone, int service, int attempts)
{
int i;
if (service <= 0 || attempts <= 0)
return FALSE;
for (i = 1; i <= attempts; i++) {
*phone = ipc_connect_me_to(PHONE_NS, service, 0);
if (*phone > 0)
return TRUE;
usleep(10000);
}
if (*phone >= 0)
return TRUE;
return FALSE;
}
int connect_to_con(int *phone, int attempts)
{
if (common_connection(phone, SERVICE_CONSOLE, attempts))
return TRUE;
return FALSE;
}
int connect_to_rd(int *phone, int attempts)
{
if (common_connection(phone, SERVICE_RD, attempts))
return TRUE;
return FALSE;
}
int connect_to_fs(int *phone, int attempts)
{
if (common_connection(phone, SERVICE_FS, attempts))
return TRUE;
return FALSE;
}