summaryrefslogtreecommitdiff
path: root/src/remove.h
blob: 8761634fbd8fa182ed136285c0b172b9384a5af6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

struct rm_options
{
  /* If nonzero, ignore nonexistent files.  */
  int ignore_missing_files;

  /* If nonzero, query the user about whether to remove each file.  */
  int interactive;

  /* If nonzero, recursively remove directories.  */
  int recursive;

  /* If nonzero, stdin is a tty.  */
  int stdin_tty;

  /* If nonzero, remove directories with unlink instead of rmdir, and don't
     require a directory to be empty before trying to unlink it.
     Only works for the super-user.  */
  int unlink_dirs;

  /* If nonzero, display the name of each file removed.  */
  int verbose;
};

enum RM_status
{
  /* These must be listed in order of increasing seriousness. */
  RM_OK = 1,
  RM_USER_DECLINED,
  RM_ERROR
};

#define VALID_STATUS(S) \
  ((S) == RM_OK || (S) == RM_USER_DECLINED || (S) == RM_ERROR)

struct File_spec
{
  char *filename;
  unsigned int have_filetype_mode:1;
  unsigned int have_full_mode:1;
  unsigned int have_device:1;
  mode_t mode;
  ino_t st_ino;
  dev_t st_dev;
};

struct dev_ino
{
  ino_t st_ino;
  dev_t st_dev;
};

enum RM_status rm PARAMS ((struct File_spec *fs,
			   int user_specified_name,
			   struct rm_options const *x,
			   struct dev_ino const *cwd_dev_ino));
void fspec_init_file PARAMS ((struct File_spec *fs, const char *filename));
void remove_init PARAMS ((struct rm_options const *x));
void remove_fini PARAMS ((void));