114 file_lock_error(msg, name, (char *)NOCATGETS("symlink(%s, %s)"),
115 (int) name, (int) lockname);
116 fprintf(stderr, "%s", msg);
117 return errno;
118 }
119
120 counter = 0;
121 for (;;) {
122 sleep(1);
123 r = lstat(lockname, &statb);
124 if (r == -1) {
125 /*
126 * The lock must have just gone away - try
127 * again.
128 */
129 break;
130 }
131
132 if ((counter > 5) && (!printed_warning)) {
133 /* Print waiting message after 5 secs */
134 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
135 (void) getcwd(msg, MAXPATHLEN);
136 #else
137 (void) getwd(msg);
138 #endif
139 fprintf(stderr,
140 catgets(libmksdmsi18n_catd, 1, 162, "file_lock: file %s is already locked.\n"),
141 name);
142 fprintf(stderr,
143 catgets(libmksdmsi18n_catd, 1, 163, "file_lock: will periodically check the lockfile %s for two minutes.\n"),
144 lockname);
145 fprintf(stderr,
146 catgets(libmksdmsi18n_catd, 1, 144, "Current working directory %s\n"),
147 msg);
148
149 printed_warning = 1;
150 }
151
152 if (++counter > timeout ) {
153 /*
154 * Waited enough - return an error..
155 */
156 return EEXIST;
157 }
158 }
160 /* NOTREACHED */
161 }
162
163 /*
164 * Format a message telling why the lock could not be created.
165 */
166 static void
167 file_lock_error(char *msg, char *file, char *str, int arg1, int arg2)
168 {
169 int len;
170
171 sprintf(msg, catgets(libmksdmsi18n_catd, 1, 145, "Could not lock file `%s'; "), file);
172 len = strlen(msg);
173 sprintf(&msg[len], str, arg1, arg2);
174 strcat(msg, catgets(libmksdmsi18n_catd, 1, 146, " failed - "));
175 #if !defined(linux)
176 if (errno < sys_nerr) {
177 #ifdef SUN4_x
178 strcat(msg, sys_errlist[errno]);
179 #endif
180 #ifdef SUN5_0
181 strcat(msg, strerror(errno));
182 #endif
183 } else {
184 len = strlen(msg);
185 sprintf(&msg[len], NOCATGETS("errno %d"), errno);
186 }
187 #else
188 strcat(msg, strerror(errno));
189 #endif
190 }
191
|
114 file_lock_error(msg, name, (char *)NOCATGETS("symlink(%s, %s)"),
115 (int) name, (int) lockname);
116 fprintf(stderr, "%s", msg);
117 return errno;
118 }
119
120 counter = 0;
121 for (;;) {
122 sleep(1);
123 r = lstat(lockname, &statb);
124 if (r == -1) {
125 /*
126 * The lock must have just gone away - try
127 * again.
128 */
129 break;
130 }
131
132 if ((counter > 5) && (!printed_warning)) {
133 /* Print waiting message after 5 secs */
134 (void) getcwd(msg, MAXPATHLEN);
135 fprintf(stderr,
136 catgets(libmksdmsi18n_catd, 1, 162, "file_lock: file %s is already locked.\n"),
137 name);
138 fprintf(stderr,
139 catgets(libmksdmsi18n_catd, 1, 163, "file_lock: will periodically check the lockfile %s for two minutes.\n"),
140 lockname);
141 fprintf(stderr,
142 catgets(libmksdmsi18n_catd, 1, 144, "Current working directory %s\n"),
143 msg);
144
145 printed_warning = 1;
146 }
147
148 if (++counter > timeout ) {
149 /*
150 * Waited enough - return an error..
151 */
152 return EEXIST;
153 }
154 }
156 /* NOTREACHED */
157 }
158
159 /*
160 * Format a message telling why the lock could not be created.
161 */
162 static void
163 file_lock_error(char *msg, char *file, char *str, int arg1, int arg2)
164 {
165 int len;
166
167 sprintf(msg, catgets(libmksdmsi18n_catd, 1, 145, "Could not lock file `%s'; "), file);
168 len = strlen(msg);
169 sprintf(&msg[len], str, arg1, arg2);
170 strcat(msg, catgets(libmksdmsi18n_catd, 1, 146, " failed - "));
171 #if !defined(linux)
172 if (errno < sys_nerr) {
173 #ifdef SUN4_x
174 strcat(msg, sys_errlist[errno]);
175 #endif
176 strcat(msg, strerror(errno));
177 } else {
178 len = strlen(msg);
179 sprintf(&msg[len], NOCATGETS("errno %d"), errno);
180 }
181 #else
182 strcat(msg, strerror(errno));
183 #endif
184 }
185
|