2
* Copyright (c) International Business Machines Corp., 2000
2
* Copyright (c) International Business Machines Corp., 2000-2002
4
4
* This program is free software; you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
6
* the Free Software Foundation; either version 2 of the License, or
7
7
* (at your option) any later version.
9
9
* This program is distributed in the hope that it will be useful,
10
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12
12
* the GNU General Public License for more details.
14
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
15
* along with this program; if not, write to the Free Software
16
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* MODULE_NAME: fsckruns.c
20
* COMPONENT_NAME: jfs utilities
29
#define INCL_DOSPROCESS
32
* defines and includes common among the xfsck modules
18
/* defines and includes common among the fsck.jfs modules */
34
19
#include "xfsckint.h"
36
21
#include <unistd.h>
39
24
extern char *MsgText[];
41
char hb_message_buffer[256];
42
char *hb_msg_ptr = &hb_message_buffer[0];
44
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
46
* For managing the heartbeat thread
48
* defined in xchkdsk.c
51
void * fsck_hbeat ( void * );
53
static pthread_t tidHbeatThread = 0;
54
int volatile exit_flag = 0;
56
26
/*****************************************************************************
34
* This is racy, but we don't care.
67
38
* failure: something else
69
void * fsck_hbeat ( void * Initial_Value )
40
void fsck_hbeat(int unused)
72
unsigned long current_heartbeat = *((unsigned long *) Initial_Value);
74
while( exit_flag == 0 ) {
76
sleep( 1); /* sleep for a second */
78
switch( current_heartbeat ) {
80
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT0] );
81
current_heartbeat = 1;
84
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT1] );
85
current_heartbeat = 2;
88
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT2] );
89
current_heartbeat = 3;
92
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT3] );
93
current_heartbeat = 4;
96
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT4] );
97
current_heartbeat = 5;
100
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT5] );
101
current_heartbeat = 6;
104
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT6] );
105
current_heartbeat = 7;
108
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT7] );
109
current_heartbeat = 8;
112
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT8] );
113
current_heartbeat = 9;
116
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT7] );
117
current_heartbeat = 10;
120
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT6] );
121
current_heartbeat = 11;
124
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT5] );
125
current_heartbeat = 12;
128
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT4] );
129
current_heartbeat = 13;
132
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT3] );
133
current_heartbeat = 14;
136
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT2] );
137
current_heartbeat = 15;
140
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT1] );
42
static volatile unsigned long current_heartbeat = 0;
44
switch (current_heartbeat) {
46
printf("%s", msg_defs[fsck_HEARTBEAT0].msg_txt);
50
printf("%s", msg_defs[fsck_HEARTBEAT1].msg_txt);
54
printf("%s", msg_defs[fsck_HEARTBEAT2].msg_txt);
58
printf("%s", msg_defs[fsck_HEARTBEAT3].msg_txt);
62
printf("%s", msg_defs[fsck_HEARTBEAT4].msg_txt);
66
printf("%s", msg_defs[fsck_HEARTBEAT5].msg_txt);
70
printf("%s", msg_defs[fsck_HEARTBEAT6].msg_txt);
74
printf("%s", msg_defs[fsck_HEARTBEAT7].msg_txt);
78
printf("%s", msg_defs[fsck_HEARTBEAT8].msg_txt);
82
printf("%s", msg_defs[fsck_HEARTBEAT7].msg_txt);
86
printf("%s", msg_defs[fsck_HEARTBEAT6].msg_txt);
90
printf("%s", msg_defs[fsck_HEARTBEAT5].msg_txt);
94
printf("%s", msg_defs[fsck_HEARTBEAT4].msg_txt);
98
printf("%s", msg_defs[fsck_HEARTBEAT3].msg_txt);
102
printf("%s", msg_defs[fsck_HEARTBEAT2].msg_txt);
106
printf("%s", msg_defs[fsck_HEARTBEAT1].msg_txt);
141
107
current_heartbeat = 0;
144
sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT0] );
110
printf("%s", msg_defs[fsck_HEARTBEAT0].msg_txt);
145
111
current_heartbeat = 1;
148
printf("%s", hb_msg_ptr );
155
/* Exit the thread. */
159
} /* end of fsck_hbeat() */
162
118
/*****************************************************************************
163
119
* NAME: fsck_hbeat_start
167
123
* PARAMETERS: none
172
126
* success: FSCK_OK
173
127
* failure: something else
175
void fsck_hbeat_start ( )
129
void fsck_hbeat_start(void)
178
unsigned long ulThreadParm = 0;
180
rc = pthread_create( &tidHbeatThread, NULL, &fsck_hbeat, &ulThreadParm);
182
if( rc != NO_ERROR ) {
187
} /* end of fsck_hbeat_start() */
133
memset(&sa, 0, sizeof (sa));
134
sa.sa_handler = &fsck_hbeat;
135
sa.sa_flags = SA_RESTART;
137
sigaction(SIGALRM, &sa, NULL);
190
141
/*****************************************************************************
191
142
* NAME: fsck_hbeat_stop