1*6a54128fSAndroid Build Coastguard Worker /* 2*6a54128fSAndroid Build Coastguard Worker * hold_inode.c --- test program which holds an inode or directory 3*6a54128fSAndroid Build Coastguard Worker * open. 4*6a54128fSAndroid Build Coastguard Worker * 5*6a54128fSAndroid Build Coastguard Worker * Copyright (C) 2000 Theodore Ts'o. 6*6a54128fSAndroid Build Coastguard Worker * 7*6a54128fSAndroid Build Coastguard Worker * %Begin-Header% 8*6a54128fSAndroid Build Coastguard Worker * This file may be redistributed under the terms of the GNU Public 9*6a54128fSAndroid Build Coastguard Worker * License. 10*6a54128fSAndroid Build Coastguard Worker * %End-Header% 11*6a54128fSAndroid Build Coastguard Worker */ 12*6a54128fSAndroid Build Coastguard Worker 13*6a54128fSAndroid Build Coastguard Worker #include "config.h" 14*6a54128fSAndroid Build Coastguard Worker #include <unistd.h> 15*6a54128fSAndroid Build Coastguard Worker #include <stdio.h> 16*6a54128fSAndroid Build Coastguard Worker #include <dirent.h> 17*6a54128fSAndroid Build Coastguard Worker #include <sys/types.h> 18*6a54128fSAndroid Build Coastguard Worker #include <sys/stat.h> 19*6a54128fSAndroid Build Coastguard Worker #include <fcntl.h> 20*6a54128fSAndroid Build Coastguard Worker 21*6a54128fSAndroid Build Coastguard Worker main(int argc,char ** argv)22*6a54128fSAndroid Build Coastguard Workermain(int argc, char **argv) 23*6a54128fSAndroid Build Coastguard Worker { 24*6a54128fSAndroid Build Coastguard Worker struct stat statbuf; 25*6a54128fSAndroid Build Coastguard Worker char *filename; 26*6a54128fSAndroid Build Coastguard Worker 27*6a54128fSAndroid Build Coastguard Worker if (argc != 2) { 28*6a54128fSAndroid Build Coastguard Worker fprintf(stderr, "Usage: %s dir\n", argv[0]); 29*6a54128fSAndroid Build Coastguard Worker exit(1); 30*6a54128fSAndroid Build Coastguard Worker } 31*6a54128fSAndroid Build Coastguard Worker filename = argv[1]; 32*6a54128fSAndroid Build Coastguard Worker if (stat(filename, &statbuf) < 0) { 33*6a54128fSAndroid Build Coastguard Worker perror(filename); 34*6a54128fSAndroid Build Coastguard Worker exit(1); 35*6a54128fSAndroid Build Coastguard Worker } 36*6a54128fSAndroid Build Coastguard Worker if (S_ISDIR(statbuf.st_mode)) { 37*6a54128fSAndroid Build Coastguard Worker if (!opendir(filename)) { 38*6a54128fSAndroid Build Coastguard Worker perror(filename); 39*6a54128fSAndroid Build Coastguard Worker exit(1); 40*6a54128fSAndroid Build Coastguard Worker } 41*6a54128fSAndroid Build Coastguard Worker } else { 42*6a54128fSAndroid Build Coastguard Worker if (open(filename, O_RDONLY) < 0) { 43*6a54128fSAndroid Build Coastguard Worker perror(filename); 44*6a54128fSAndroid Build Coastguard Worker exit(1); 45*6a54128fSAndroid Build Coastguard Worker } 46*6a54128fSAndroid Build Coastguard Worker } 47*6a54128fSAndroid Build Coastguard Worker sleep(30); 48*6a54128fSAndroid Build Coastguard Worker } 49