"Fossies" - the Fresh Open Source Software Archive 
Member "shake-1.0/judge.h" (15 Nov 2014, 4117 Bytes) of package /linux/privat/shake-1.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "judge.h" see the
Fossies "Dox" file reference documentation.
1 /***************************************************************************/
2 /* Copyright (C) 2006-2009 Brice Arnould. */
3 /* */
4 /* This file is part of ShaKe. */
5 /* */
6 /* ShaKe 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 3 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 the */
14 /* 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, see <http://www.gnu.org/licenses/>. */
18 /***************************************************************************/
19
20 #ifndef JUDGE_H
21 # define JUDGE_H
22 #include <stdbool.h>
23 #include <fcntl.h>
24 #include <time.h>
25 #include <sys/stat.h>
26
27 typedef unsigned int uint;
28 typedef long long int llint;
29
30 /* The distance at wich two adjacent block are considered as two
31 *fragment (in byte). ~=(readahead_of_most_disks*2)
32 */
33 //const uint MAGICLEAP = 2* 32 * 1024;
34 #define MAGICLEAP (2* 32 * 1024)
35
36 /* The time between wich two file are considered as used together
37 * (in seconds)
38 */
39 #define MAGICTIME ( 8 )
40
41 /* File with this tolerance won't be defrag
42 */
43 #define MAX_TOL ( -1.0 )
44
45 struct law
46 {
47 uint maxfragc; // max number of fragments
48 double crumbratio; // ratio of the file, a smaller fragment is a crumb
49 uint maxcrumbc; // Allowed number of fragment smaller than crumbratio
50 off_t smallsize; // the size under which a file is considered small
51 off_t bigsize; // the size from which a file is considered as big
52 double smallsize_tol; // multiply crumbratio and divide maxfnumber of small files
53 double bigsize_tol; // " " " " " for big files
54 uint maxdeviance; // max distance between file start and it's ideal pos
55 time_t old; // Age of "old" files, will be shak()ed
56 time_t new; // Age of "new" files, won't be shak()ed
57 bool pretend; // simulate
58 int verbosity; // set the verbose mode
59 bool locks; // put a lock on written files
60 dev_t kingdom; // file system to examine, ignored if (-1)
61 bool xattr; // use user_xattr
62 int tmpfd;
63 char *tmpname;
64 };
65
66 /* The file or directory accused of being fragmented
67 * Fields are here in the order they are set.
68 */
69 struct accused
70 {
71 mode_t mode;
72 char *name;
73 int fd;
74 off_t size;
75 long blocks; // Number of blocks
76 uint fragc; // Number of fragments
77 uint crumbc; // Number of fragments smaller than crumbratio
78 llint start; // The position of the first block
79 llint end; // The position of the first block
80 llint ideal; // Where the file would idealy start
81 time_t atime; // atime, as returned by stat
82 time_t mtime; // ctime, as returned by stat
83 time_t age; // Min of (atime,ctime,mtime)
84 llint *poslog; // Tab of fragments positions
85 llint *sizelog; // Tab of fragments sizes
86 dev_t fs;
87 bool guilty;
88 };
89
90 /* This function return a struct wich describe properties
91 * of the file who's name is given.
92 */
93 struct accused *investigate (char *name, struct law *l);
94
95 /* This function free structs allocated by
96 * investigate().
97 */
98 void close_case (struct accused *a, struct law *l);
99
100
101
102 /* This function call judge on stdin content
103 */
104 int judge_stdin (struct accused *a, struct law *l);
105
106 /* Return true if the file is fragmented, else false.
107 */
108 int judge (struct accused *a, struct law *l);
109
110 #endif /* JUDGE_H */