summaryrefslogtreecommitdiffstats
path: root/xlators/features/trash/src/trash.h
blob: 65c0ed857122f743bc2cfc284bd622b311024e72 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
  Copyright (c) 2006-2009 Gluster, Inc. <http://www.gluster.com>
  This file is part of GlusterFS.

  GlusterFS is free software; you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published
  by the Free Software Foundation; either version 3 of the License,
  or (at your option) any later version.

  GlusterFS is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see
  <http://www.gnu.org/licenses/>.
*/

#ifndef __TRASH_H__
#define __TRASH_H__

#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif

#include "glusterfs.h"
#include "logging.h"
#include "dict.h"
#include "xlator.h"
#include "defaults.h"
#include "inode.c"
#include "fnmatch.h"

#include <libgen.h>

#ifndef GF_BLOCK_READV_SIZE
#define GF_BLOCK_READV_SIZE      (128 * GF_UNIT_KB)
#endif

#ifndef GF_DEFAULT_MAX_FILE_SIZE
#define GF_DEFAULT_MAX_FILE_SIZE (200 * GF_UNIT_MB)
#endif

#ifndef GF_ALLOWED_MAX_FILE_SIZE
#define GF_ALLOWED_MAX_FILE_SIZE (1 * GF_UNIT_GB)
#endif


struct trash_struct {
        fd_t    *fd;         /* for the fd of existing file */
        fd_t    *newfd;      /* for the newly created file */
        loc_t    loc;        /* to store the location of the existing file */
        loc_t    newloc;     /* to store the location for the new file */
        size_t   fsize;      /* for keeping the size of existing file */
        off_t    cur_offset; /* current offset for read and write ops */
        off_t    fop_offset;
        char     origpath[PATH_MAX];
        char     newpath[PATH_MAX];
        int32_t  loop_count;
        struct iatt preparent;
        struct iatt postparent;
};
typedef struct trash_struct trash_local_t;

struct _trash_elim_pattern;
typedef struct _trash_elim_pattern {
        struct _trash_elim_pattern *next;
        char                       *pattern;
} trash_elim_pattern_t;

struct trash_priv {
        char                 *trash_dir;
        trash_elim_pattern_t *eliminate;
        size_t                max_trash_file_size;
};
typedef struct trash_priv trash_private_t;

#define TRASH_STACK_UNWIND(op, frame, params ...) do {     \
		trash_local_t *__local = NULL;         \
		__local = frame->local;                \
		frame->local = NULL;		       \
		STACK_UNWIND_STRICT (op, frame, params);          \
		trash_local_wipe (__local);	       \
	} while (0)


#endif /* __TRASH_H__ */