blob: 7c1ad04425fbc5fe6fad9f4a3c1d549989ee1128 [file] [log] [blame]
robbiew24e30ab2003-01-07 20:53:21 +00001/*
2 *
3 * Copyright (c) International Business Machines Corp., 2002
subrata_modak04f47a12009-09-18 17:44:08 +00004 * Copyright (c) Cyril Hrubis chrubis@suse.cz 2009
robbiew24e30ab2003-01-07 20:53:21 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
14 * the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Wanlong Gao4548c6c2012-10-19 18:03:36 +080018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
robbiew24e30ab2003-01-07 20:53:21 +000019 */
20
21/*
22 * NAME
23 * ftest06.c -- test inode things (ported from SPIE section2/filesuite/ftest7.c, by Airong Zhang)
24 *
25 * this is the same as ftest2, except that it uses lseek64
26 *
27 * CALLS
28 * open, close, read, write, llseek,
29 * unlink, chdir
subrata_modakbdbaec52009-02-26 12:14:51 +000030 *
robbiew24e30ab2003-01-07 20:53:21 +000031 *
32 * ALGORITHM
33 *
34 * This was tino.c by rbk. Moved to test suites by dale.
35 *
36 * ftest06 [-f tmpdirname] nchild iterations [partition]
37 *
38 * This forks some child processes, they do some random operations
39 * which use lots of directory operations.
40 *
41 * RESTRICTIONS
42 * Runs a long time with default args - can take others on input
43 * line. Use with "term mode".
44 * If run on vax the ftruncate will not be random - will always go to
45 * start of file. NOTE: produces a very high load average!!
46 *
47 */
48
subrata_modak04f47a12009-09-18 17:44:08 +000049#define _LARGEFILE64_SOURCE 1
50#include <stdio.h>
robbiew24e30ab2003-01-07 20:53:21 +000051#include <sys/types.h>
52#include <sys/param.h>
53#include <fcntl.h>
54#include <sys/stat.h>
55#include <sys/mount.h>
56#include <sys/wait.h>
vapierf81795e2006-02-15 06:28:58 +000057#include <errno.h>
subrata_modak04f47a12009-09-18 17:44:08 +000058#include <signal.h>
robbiew24e30ab2003-01-07 20:53:21 +000059#include <unistd.h>
60#include "test.h"
61#include "usctest.h"
subrata_modak04f47a12009-09-18 17:44:08 +000062#include "libftest.h"
robbiew24e30ab2003-01-07 20:53:21 +000063
64char *TCID = "ftest06";
65int TST_TOTAL = 1;
robbiew24e30ab2003-01-07 20:53:21 +000066
67#define PASSED 1
68#define FAILED 0
69
subrata_modak04f47a12009-09-18 17:44:08 +000070static void crfile(int, int);
71static void unlfile(int, int);
72static void fussdir(int, int);
73static void dotest(int, int);
74static void dowarn(int, char*, char*);
75static void term(int sig);
76static void cleanup(void);
robbiew24e30ab2003-01-07 20:53:21 +000077
subrata_modak04f47a12009-09-18 17:44:08 +000078#define MAXCHILD 25
robbiew24e30ab2003-01-07 20:53:21 +000079#define K_1 1024
80#define K_2 2048
81#define K_4 4096
82
subrata_modak04f47a12009-09-18 17:44:08 +000083static int local_flag;
robbiew24e30ab2003-01-07 20:53:21 +000084
robbiew24e30ab2003-01-07 20:53:21 +000085#define M (1024*1024)
86
subrata_modak04f47a12009-09-18 17:44:08 +000087static int iterations;
88static int nchild;
89static int parent_pid;
90static int pidlist[MAXCHILD];
robbiew24e30ab2003-01-07 20:53:21 +000091
subrata_modak04f47a12009-09-18 17:44:08 +000092static char homedir[MAXPATHLEN];
93static char dirname[MAXPATHLEN];
subrata_modak04f47a12009-09-18 17:44:08 +000094static int dirlen;
95static int mnt = 0;
96static char startdir[MAXPATHLEN], mntpoint[MAXPATHLEN];
97static char *partition;
98static char *cwd;
99static char *fstyp;
robbiew24e30ab2003-01-07 20:53:21 +0000100
subrata_modak04f47a12009-09-18 17:44:08 +0000101int main(int ac, char *av[])
robbiew24e30ab2003-01-07 20:53:21 +0000102{
subrata_modak04f47a12009-09-18 17:44:08 +0000103 int pid, child, status, count, k, j;
104 char name[3];
robbiew24e30ab2003-01-07 20:53:21 +0000105
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800106 int lc;
107 char *msg;
robbiew24e30ab2003-01-07 20:53:21 +0000108
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800109 /*
110 * parse standard options
111 */
Garrett Cooper0ff96ab2011-03-15 05:16:05 -0700112 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800113 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
robbiew24e30ab2003-01-07 20:53:21 +0000114
robbiew24e30ab2003-01-07 20:53:21 +0000115 /*
116 * Default values for run conditions.
117 */
robbiew24e30ab2003-01-07 20:53:21 +0000118 iterations = 50;
119 nchild = 5;
120
subrata_modak04f47a12009-09-18 17:44:08 +0000121 if (signal(SIGTERM, term) == SIG_ERR) {
vapieraf64a872006-02-15 06:47:36 +0000122 tst_resm(TBROK,"first signal failed");
Garrett Cooper2c282152010-12-16 00:55:50 -0800123
robbiew24e30ab2003-01-07 20:53:21 +0000124 }
125
126 /* use the default values for run conditions */
subrata_modak4bb656a2009-02-26 12:02:09 +0000127 for (lc = 0; TEST_LOOPING(lc); lc++) {
robbiew24e30ab2003-01-07 20:53:21 +0000128
129 local_flag = PASSED;
130 /*
131 * Make a directory to do this in; ignore error if already exists.
132 */
robbiew24e30ab2003-01-07 20:53:21 +0000133 parent_pid = getpid();
134 tst_tmpdir();
135
136 if (!startdir[0]) {
137 if (getcwd(startdir, MAXPATHLEN) == NULL) {
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800138 tst_brkm(TFAIL|TERRNO, NULL, "getcwd failed");
robbiew24e30ab2003-01-07 20:53:21 +0000139 }
subrata_modak04f47a12009-09-18 17:44:08 +0000140 }
robbiew24e30ab2003-01-07 20:53:21 +0000141 cwd = startdir;
Chris Dearman37550cf2012-10-17 19:54:01 -0700142
Cyril Hrubisa33bc182011-03-16 14:41:10 +0100143 snprintf(dirname, ARRAY_SIZE(dirname),
144 "%s/ftest06.%d", cwd, getpid());
145 snprintf(homedir, ARRAY_SIZE(homedir),
146 "%s/ftest06h.%d", cwd, getpid());
robbiew24e30ab2003-01-07 20:53:21 +0000147
148 mkdir(dirname, 0755);
149 mkdir(homedir, 0755);
Cyril Hrubisa33bc182011-03-16 14:41:10 +0100150
151 if (chdir(dirname) < 0)
Garrett Cooperf01306b2010-11-05 11:14:08 -0700152 tst_brkm(TFAIL|TERRNO, cleanup, "\tCan't chdir(%s)", dirname);
Chris Dearman37550cf2012-10-17 19:54:01 -0700153
robbiew24e30ab2003-01-07 20:53:21 +0000154 dirlen = strlen(dirname);
Cyril Hrubisa33bc182011-03-16 14:41:10 +0100155
156 if (chdir(homedir) < 0)
Garrett Cooperf01306b2010-11-05 11:14:08 -0700157 tst_brkm(TFAIL|TERRNO, cleanup, "\tCan't chdir(%s)", homedir);
robbiew24e30ab2003-01-07 20:53:21 +0000158
159 /* enter block */
subrata_modak04f47a12009-09-18 17:44:08 +0000160 for (k = 0; k < nchild; k++) {
161 if ((child = fork()) == 0) {
162 dotest(k, iterations);
Garrett Cooper0ff96ab2011-03-15 05:16:05 -0700163 tst_exit();
robbiew24e30ab2003-01-07 20:53:21 +0000164 }
165 if (child < 0) {
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800166 tst_brkm(TBROK|TERRNO, cleanup, "fork failed");
robbiew24e30ab2003-01-07 20:53:21 +0000167 }
168 pidlist[k] = child;
169 }
170
171 /*
172 * Wait for children to finish.
173 */
robbiew24e30ab2003-01-07 20:53:21 +0000174 count = 0;
subrata_modak04f47a12009-09-18 17:44:08 +0000175 while ((child = wait(&status)) > 0) {
vapieraf64a872006-02-15 06:47:36 +0000176 //tst_resm(TINFO,"Test{%d} exited status = 0x%x", child, status);
177 //fprintf(stdout, "status is %d",status);
robbiew24e30ab2003-01-07 20:53:21 +0000178 if (status) {
vapieraf64a872006-02-15 06:47:36 +0000179 tst_resm(TFAIL,"Test{%d} failed, expected 0 exit.", child);
robbiew24e30ab2003-01-07 20:53:21 +0000180 local_flag = FAILED;
181 }
182 ++count;
183 }
184
185 /*
186 * Should have collected all children.
187 */
robbiew24e30ab2003-01-07 20:53:21 +0000188 if (count != nchild) {
vapieraf64a872006-02-15 06:47:36 +0000189 tst_resm(TFAIL,"Wrong # children waited on, count = %d", count);
robbiew24e30ab2003-01-07 20:53:21 +0000190 local_flag = FAILED;
191 }
192
subrata_modak04f47a12009-09-18 17:44:08 +0000193 if (local_flag == PASSED)
194 tst_resm(TPASS, "Test passed.");
195 else
196 tst_resm(TFAIL, "Test failed.");
robbiew24e30ab2003-01-07 20:53:21 +0000197
198 if (iterations > 26)
199 iterations = 26;
subrata_modak04f47a12009-09-18 17:44:08 +0000200
201 for (k = 0; k < nchild; k++)
202 for (j = 0; j < iterations + 1; j++) {
203 ft_mkname(name, dirname, k, j);
robbiew24e30ab2003-01-07 20:53:21 +0000204 rmdir(name);
205 unlink(name);
206 }
207
Cyril Hrubisa33bc182011-03-16 14:41:10 +0100208 if (chdir(startdir) < 0)
209 tst_brkm(TFAIL|TERRNO, cleanup, "Can't chdir(%s)", startdir);
robbiew24e30ab2003-01-07 20:53:21 +0000210
211 pid = fork();
212 if (pid < 0) {
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800213 tst_brkm(TBROK|TERRNO, NULL, "fork failed");
robbiew24e30ab2003-01-07 20:53:21 +0000214 }
subrata_modak04f47a12009-09-18 17:44:08 +0000215
robbiew24e30ab2003-01-07 20:53:21 +0000216 if (pid == 0) {
robbiew7fdd5142005-02-07 19:39:54 +0000217 execl("/bin/rm", "rm", "-rf", homedir, NULL);
Garrett Cooper2c282152010-12-16 00:55:50 -0800218
robbiew24e30ab2003-01-07 20:53:21 +0000219 } else
220 wait(&status);
subrata_modak04f47a12009-09-18 17:44:08 +0000221
robbiew24e30ab2003-01-07 20:53:21 +0000222 if (status)
vapieraf64a872006-02-15 06:47:36 +0000223 tst_resm(TINFO,"CAUTION - ftest06, '%s' may not have been removed.",
robbiew24e30ab2003-01-07 20:53:21 +0000224 homedir);
225
226 pid = fork();
227 if (pid < 0) {
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800228 tst_brkm(TBROK|TERRNO, NULL, "fork failed");
robbiew24e30ab2003-01-07 20:53:21 +0000229 }
230 if (pid == 0) {
robbiew7fdd5142005-02-07 19:39:54 +0000231 execl("/bin/rm", "rm", "-rf", dirname, NULL);
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800232 exit(1);
robbiew24e30ab2003-01-07 20:53:21 +0000233 } else
234 wait(&status);
235 if (status) {
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800236 tst_resm(TWARN, "CAUTION - ftest06, '%s' may not have been removed.",
robbiew24e30ab2003-01-07 20:53:21 +0000237 dirname);
238 }
239
subrata_modak04f47a12009-09-18 17:44:08 +0000240 sync();
robbiew24e30ab2003-01-07 20:53:21 +0000241
subrata_modak04f47a12009-09-18 17:44:08 +0000242 }
243
244 if (local_flag == FAILED)
Garrett Cooper7a73eab2010-11-09 22:45:42 -0800245 tst_resm(TFAIL, "Test failed.");
246 else
247 tst_resm(TPASS, "Test passed.");
robbiew24e30ab2003-01-07 20:53:21 +0000248
249 cleanup();
Garrett Cooperb0a973a2011-01-21 01:15:32 -0800250 tst_exit();
robbiew24e30ab2003-01-07 20:53:21 +0000251}
252
subrata_modak04f47a12009-09-18 17:44:08 +0000253#define warn(val,m1,m2) if ((val) < 0) dowarn(me,m1,m2)
robbiew24e30ab2003-01-07 20:53:21 +0000254
255/*
256 * crfile()
257 * Create a file and write something into it.
258 */
subrata_modak04f47a12009-09-18 17:44:08 +0000259static char crmsg[] = "Gee, let's write something in the file!\n";
robbiew24e30ab2003-01-07 20:53:21 +0000260
subrata_modak04f47a12009-09-18 17:44:08 +0000261static void crfile(int me, int count)
robbiew24e30ab2003-01-07 20:53:21 +0000262{
263 int fd;
264 off64_t seekval;
265 int val;
Garrett Cooperfde57722010-08-16 23:37:16 -0700266 char fname[MAXPATHLEN];
267 char buf[MAXPATHLEN];
robbiew24e30ab2003-01-07 20:53:21 +0000268
subrata_modak04f47a12009-09-18 17:44:08 +0000269 ft_mkname(fname, dirname, me, count);
robbiew24e30ab2003-01-07 20:53:21 +0000270
271 fd = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0666);
272 if (fd < 0 && errno == EISDIR) {
273 val = rmdir(fname);
274 warn(val, "rmdir", fname);
275 fd = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0666);
276 }
277 warn(fd, "creating", fname);
278
279 seekval = lseek64(fd, (off64_t)(rand() % M), 0);
280 warn(seekval, "lseek64", 0);
281
282 val = write(fd, crmsg, sizeof(crmsg)-1);
283 warn(val, "write", 0);
284
285 seekval = lseek(fd, -((off64_t)sizeof(crmsg)-1), 1);
286 warn(seekval, "lseek64", 0);
287
288 val = read(fd, buf, sizeof(crmsg)-1);
289 warn(val, "read", 0);
290
subrata_modak04f47a12009-09-18 17:44:08 +0000291 if (strncmp(crmsg, buf, sizeof(crmsg)-1))
292 dowarn(me, "compare", 0);
robbiew24e30ab2003-01-07 20:53:21 +0000293
294 val = close(fd);
295 warn(val, "close", 0);
296}
297
298/*
299 * unlfile()
300 * Unlink some of the files.
301 */
subrata_modak04f47a12009-09-18 17:44:08 +0000302static void unlfile(int me, int count)
robbiew24e30ab2003-01-07 20:53:21 +0000303{
subrata_modak04f47a12009-09-18 17:44:08 +0000304 int val, i;
Garrett Cooperfde57722010-08-16 23:37:16 -0700305 char fname[MAXPATHLEN];
robbiew24e30ab2003-01-07 20:53:21 +0000306
307 i = count - 10;
308 if (i < 0)
309 i = 0;
subrata_modak04f47a12009-09-18 17:44:08 +0000310 for (; i < count; i++) {
311 ft_mkname(fname, dirname, me, i);
robbiew24e30ab2003-01-07 20:53:21 +0000312 val = rmdir(fname);
Garrett Cooper8fb1cdb2010-11-28 22:56:35 -0800313 if (val < 0)
robbiew24e30ab2003-01-07 20:53:21 +0000314 val = unlink(fname);
315 if (val == 0 || errno == ENOENT)
316 continue;
subrata_modak04f47a12009-09-18 17:44:08 +0000317 dowarn(me, "unlink", fname);
robbiew24e30ab2003-01-07 20:53:21 +0000318 }
319}
320
321/*
322 * fussdir()
323 * Make a directory, put stuff in it, remove it, and remove directory.
324 *
325 * Randomly leave the directory there.
326 */
subrata_modak04f47a12009-09-18 17:44:08 +0000327static void fussdir(int me, int count)
robbiew24e30ab2003-01-07 20:53:21 +0000328{
subrata_modak04f47a12009-09-18 17:44:08 +0000329 int val;
Garrett Cooperfde57722010-08-16 23:37:16 -0700330 char dir[MAXPATHLEN], fname[MAXPATHLEN], savedir[MAXPATHLEN];
robbiew24e30ab2003-01-07 20:53:21 +0000331
subrata_modak04f47a12009-09-18 17:44:08 +0000332 ft_mkname(dir, dirname, me, count);
333 rmdir(dir);
334 unlink(dir);
robbiew24e30ab2003-01-07 20:53:21 +0000335
336 val = mkdir(dir, 0755);
337 warn(val, "mkdir", dir);
338
339 /*
340 * Arrange to create files in the directory.
341 */
robbiew24e30ab2003-01-07 20:53:21 +0000342 strcpy(savedir, dirname);
343 strcpy(dirname, "");
344
345 val = chdir(dir);
346 warn(val, "chdir", dir);
347
348 crfile(me, count);
349 crfile(me, count+1);
350
351 val = chdir("..");
352 warn(val, "chdir", "..");
353
354 val = rmdir(dir);
subrata_modak04f47a12009-09-18 17:44:08 +0000355
robbiew24e30ab2003-01-07 20:53:21 +0000356 if (val >= 0) {
vapieraf64a872006-02-15 06:47:36 +0000357 tst_resm(TFAIL,"Test[%d]: rmdir of non-empty %s succeeds!", me, dir);
robbiew24e30ab2003-01-07 20:53:21 +0000358 tst_exit();
359 }
360
361 val = chdir(dir);
362 warn(val, "chdir", dir);
363
subrata_modak04f47a12009-09-18 17:44:08 +0000364 ft_mkname(fname, dirname, me, count);
robbiew24e30ab2003-01-07 20:53:21 +0000365 val = unlink(fname);
366 warn(val, "unlink", fname);
367
subrata_modak04f47a12009-09-18 17:44:08 +0000368 ft_mkname(fname, dirname, me, count+1);
robbiew24e30ab2003-01-07 20:53:21 +0000369 val = unlink(fname);
370 warn(val, "unlink", fname);
371
372 val = chdir(homedir);
373 warn(val, "chdir", homedir);
374
375 if (rand() & 0x01) {
376 val = rmdir(dir);
377 warn(val, "rmdir", dir);
378 }
379
380 strcpy(dirname, savedir);
381}
382
robbiew24e30ab2003-01-07 20:53:21 +0000383/*
384 * dotest()
385 * Children execute this.
386 *
387 * Randomly do an inode thing; loop for # iterations.
388 */
robbiew24e30ab2003-01-07 20:53:21 +0000389#define THING(p) {p, "p"}
390
391struct ino_thing {
392 void (*it_proc)();
393 char *it_name;
394} ino_thing[] = {
395 THING(crfile),
396 THING(unlfile),
397 THING(fussdir),
398 THING(sync),
399};
400
401#define NTHING (sizeof(ino_thing) / sizeof(ino_thing[0]))
402
403int thing_cnt[NTHING];
404int thing_last[NTHING];
405
subrata_modak04f47a12009-09-18 17:44:08 +0000406static void dotest(int me, int count)
robbiew24e30ab2003-01-07 20:53:21 +0000407{
subrata_modak04f47a12009-09-18 17:44:08 +0000408 int thing, i;
robbiew24e30ab2003-01-07 20:53:21 +0000409
vapieraf64a872006-02-15 06:47:36 +0000410 //tst_resm(TINFO,"Test %d pid %d starting.", me, getpid());
robbiew24e30ab2003-01-07 20:53:21 +0000411
412 srand(getpid());
subrata_modak04f47a12009-09-18 17:44:08 +0000413
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800414 for (i = 0; i < count; i++) {
robbiew24e30ab2003-01-07 20:53:21 +0000415 thing = (rand() >> 3) % NTHING;
416 (*ino_thing[thing].it_proc)(me, i, ino_thing[thing].it_name);
417 ++thing_cnt[thing];
418 }
419
vapieraf64a872006-02-15 06:47:36 +0000420 //tst_resm(TINFO,"Test %d pid %d exiting.", me, getpid());
robbiew24e30ab2003-01-07 20:53:21 +0000421}
422
subrata_modak04f47a12009-09-18 17:44:08 +0000423static void dowarn(int me, char *m1, char *m2)
robbiew24e30ab2003-01-07 20:53:21 +0000424{
subrata_modak04f47a12009-09-18 17:44:08 +0000425 int err = errno;
robbiew24e30ab2003-01-07 20:53:21 +0000426
vapieraf64a872006-02-15 06:47:36 +0000427 tst_resm(TFAIL,"Test[%d]: error %d on %s %s",
robbiew24e30ab2003-01-07 20:53:21 +0000428 me, err, m1, (m2 ? m2 : ""));
429 tst_exit();
430}
431
subrata_modak04f47a12009-09-18 17:44:08 +0000432static void term(int sig LTP_ATTRIBUTE_UNUSED)
robbiew24e30ab2003-01-07 20:53:21 +0000433{
subrata_modak04f47a12009-09-18 17:44:08 +0000434 int i;
robbiew24e30ab2003-01-07 20:53:21 +0000435
vapieraf64a872006-02-15 06:47:36 +0000436 tst_resm(TINFO, "\tterm -[%d]- got sig term.", getpid());
subrata_modakbdbaec52009-02-26 12:14:51 +0000437
robbiew24e30ab2003-01-07 20:53:21 +0000438 if (parent_pid == getpid()) {
subrata_modak04f47a12009-09-18 17:44:08 +0000439 for (i = 0; i < nchild; i++)
440 if (pidlist[i])
robbiew24e30ab2003-01-07 20:53:21 +0000441 kill(pidlist[i], SIGTERM);
subrata_modak04f47a12009-09-18 17:44:08 +0000442 return;
robbiew24e30ab2003-01-07 20:53:21 +0000443 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000444
vapieraf64a872006-02-15 06:47:36 +0000445 tst_resm(TBROK, "Term: Child process exiting.");
robbiew24e30ab2003-01-07 20:53:21 +0000446 tst_exit();
robbiew24e30ab2003-01-07 20:53:21 +0000447}
448
subrata_modak04f47a12009-09-18 17:44:08 +0000449static void cleanup(void)
robbiew24e30ab2003-01-07 20:53:21 +0000450{
451 char mount_buffer[1024];
452
453 if (mnt == 1) {
454 if (chdir(startdir) < 0) {
vapieraf64a872006-02-15 06:47:36 +0000455 tst_resm(TINFO,"Could not change to %s ", startdir);
robbiew24e30ab2003-01-07 20:53:21 +0000456 }
457 if (!strcmp(fstyp, "cfs")) {
subrata_modak04f47a12009-09-18 17:44:08 +0000458 sprintf(mount_buffer, "/bin/umount %s", partition);
robbiew24e30ab2003-01-07 20:53:21 +0000459 if (system(mount_buffer) != 0) {
vapieraf64a872006-02-15 06:47:36 +0000460 tst_resm(TINFO,"Unable to unmount %s from %s ", partition, mntpoint);
robbiew24e30ab2003-01-07 20:53:21 +0000461 if (umount(partition)) {
vapieraf64a872006-02-15 06:47:36 +0000462 tst_resm(TINFO,"Unable to unmount %s from %s ", partition, mntpoint);
robbiew24e30ab2003-01-07 20:53:21 +0000463 }
464 else {
subrata_modak04f47a12009-09-18 17:44:08 +0000465 tst_resm(TINFO, "Forced umount for %s, /etc/mtab now dirty", partition );
robbiew24e30ab2003-01-07 20:53:21 +0000466 }
467 }
468 }
469 else {
470 if (umount(partition)) {
vapieraf64a872006-02-15 06:47:36 +0000471 tst_resm(TINFO,"Unable to unmount %s from %s ", partition, mntpoint);
robbiew24e30ab2003-01-07 20:53:21 +0000472 }
473 }
474 if (rmdir(mntpoint) != 0) {
vapieraf64a872006-02-15 06:47:36 +0000475 tst_resm(TINFO,"Unable to rmdir %s ", mntpoint);
robbiew24e30ab2003-01-07 20:53:21 +0000476 }
477 }
478 tst_rmdir();
Garrett Cooper2c282152010-12-16 00:55:50 -0800479
Garrett Cooperb0a973a2011-01-21 01:15:32 -0800480}