Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2393 | konopa | 1 | /* Functions for connecting to some services, which is needed for FS. */ |
2 | |||
3 | /* Methods: |
||
4 | * common_connection: includes common aspects for connecting to some services |
||
5 | * con_connection: connects to SERVICE_CONSOLE |
||
6 | * rd_connection: connects to SERVICE_RD |
||
7 | * fs_connection: connects to SERVICE_FS |
||
8 | * |
||
9 | */ |
||
10 | |||
11 | #include <ipc/ipc.h> |
||
12 | #include <ipc/services.h> |
||
13 | #include "../fs/fs.h" |
||
14 | |||
15 | |||
16 | int common_connection(int *phone, int service, int attempts) |
||
17 | { |
||
18 | |||
19 | int i; |
||
20 | |||
21 | if (service <= 0 || attempts <= 0) |
||
22 | return FALSE; |
||
23 | |||
24 | for (i = 1; i <= attempts; i++) { |
||
25 | *phone = ipc_connect_me_to(PHONE_NS, service, 0); |
||
26 | |||
27 | if (*phone > 0) |
||
28 | return TRUE; |
||
29 | |||
30 | usleep(10000); |
||
31 | } |
||
32 | |||
33 | if (*phone >= 0) |
||
34 | return TRUE; |
||
35 | |||
36 | return FALSE; |
||
37 | } |
||
38 | |||
39 | |||
40 | int connect_to_con(int *phone, int attempts) |
||
41 | { |
||
42 | |||
43 | if (common_connection(phone, SERVICE_CONSOLE, attempts)) |
||
44 | return TRUE; |
||
45 | |||
46 | return FALSE; |
||
47 | } |
||
48 | |||
49 | int connect_to_rd(int *phone, int attempts) |
||
50 | { |
||
51 | |||
52 | if (common_connection(phone, SERVICE_RD, attempts)) |
||
53 | return TRUE; |
||
54 | |||
55 | return FALSE; |
||
56 | } |
||
57 | |||
58 | int connect_to_fs(int *phone, int attempts) |
||
59 | { |
||
60 | |||
61 | if (common_connection(phone, SERVICE_FS, attempts)) |
||
62 | return TRUE; |
||
63 | |||
64 | return FALSE; |
||
65 | } |