1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved. 4f08c3bdfSopenharmony_ci * Author: Nirmala Devi Dhanasekar <nirmala.devi@wipro.com> 5f08c3bdfSopenharmony_ci * 6f08c3bdfSopenharmony_ci * Phase I test for the umount(2) system call. 7f08c3bdfSopenharmony_ci * It is intended to provide a limited exposure of the system call. 8f08c3bdfSopenharmony_ci */ 9f08c3bdfSopenharmony_ci 10f08c3bdfSopenharmony_ci#include <errno.h> 11f08c3bdfSopenharmony_ci#include <sys/mount.h> 12f08c3bdfSopenharmony_ci#include "tst_test.h" 13f08c3bdfSopenharmony_ci 14f08c3bdfSopenharmony_ci#define MNTPOINT "mntpoint" 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_cistatic int mount_flag; 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_cistatic void verify_umount(void) 19f08c3bdfSopenharmony_ci{ 20f08c3bdfSopenharmony_ci if (mount_flag != 1) { 21f08c3bdfSopenharmony_ci SAFE_MOUNT(tst_device->dev, MNTPOINT, 22f08c3bdfSopenharmony_ci tst_device->fs_type, 0, NULL); 23f08c3bdfSopenharmony_ci mount_flag = 1; 24f08c3bdfSopenharmony_ci } 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci TEST(umount(MNTPOINT)); 27f08c3bdfSopenharmony_ci 28f08c3bdfSopenharmony_ci if (TST_RET != 0 && TST_ERR == EBUSY) { 29f08c3bdfSopenharmony_ci tst_res(TINFO, "umount() Failed with EBUSY " 30f08c3bdfSopenharmony_ci "possibly some daemon (gvfsd-trash) " 31f08c3bdfSopenharmony_ci "is probing newly mounted dirs"); 32f08c3bdfSopenharmony_ci } 33f08c3bdfSopenharmony_ci 34f08c3bdfSopenharmony_ci if (TST_RET != 0) { 35f08c3bdfSopenharmony_ci tst_res(TFAIL | TTERRNO, "umount() Failed"); 36f08c3bdfSopenharmony_ci return; 37f08c3bdfSopenharmony_ci } 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ci tst_res(TPASS, "umount() Passed"); 40f08c3bdfSopenharmony_ci mount_flag = 0; 41f08c3bdfSopenharmony_ci} 42f08c3bdfSopenharmony_ci 43f08c3bdfSopenharmony_cistatic void setup(void) 44f08c3bdfSopenharmony_ci{ 45f08c3bdfSopenharmony_ci SAFE_MKDIR(MNTPOINT, 0775); 46f08c3bdfSopenharmony_ci} 47f08c3bdfSopenharmony_ci 48f08c3bdfSopenharmony_cistatic void cleanup(void) 49f08c3bdfSopenharmony_ci{ 50f08c3bdfSopenharmony_ci if (mount_flag) 51f08c3bdfSopenharmony_ci tst_umount(MNTPOINT); 52f08c3bdfSopenharmony_ci} 53f08c3bdfSopenharmony_ci 54f08c3bdfSopenharmony_cistatic struct tst_test test = { 55f08c3bdfSopenharmony_ci .needs_root = 1, 56f08c3bdfSopenharmony_ci .format_device = 1, 57f08c3bdfSopenharmony_ci .setup = setup, 58f08c3bdfSopenharmony_ci .cleanup = cleanup, 59f08c3bdfSopenharmony_ci .test_all = verify_umount, 60f08c3bdfSopenharmony_ci}; 61