File: 12_cachesize_permissions.diff

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (83 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download | duplicates (15)
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
--- stats.c	(révision 8804)
+++ stats.c	(copie de travail)
@@ -286,7 +286,7 @@
 
 
 /* set the per directory limits */
-void stats_set_limits(long maxfiles, long maxsize)
+int stats_set_limits(long maxfiles, long maxsize)
 {
 	int dir;
 	unsigned counters[STATS_END];
@@ -298,7 +298,9 @@
 		maxsize /= 16;
 	}
 
-	create_dir(cache_dir);
+	if (create_dir(cache_dir) != 0) {
+		return 1;
+	}
 
 	/* set the limits in each directory */
 	for (dir=0;dir<=0xF;dir++) {
@@ -306,7 +308,9 @@
 		int fd;
 
 		x_asprintf(&cdir, "%s/%1x", cache_dir, dir);
-		create_dir(cdir);
+		if (create_dir(cdir) != 0) {
+			return 1;
+		}
 		x_asprintf(&fname, "%s/stats", cdir);
 		free(cdir);
 
@@ -326,6 +330,8 @@
 		}
 		free(fname);
 	}
+
+	return 0;
 }
 
 /* set the per directory sizes */
--- ccache.c	(révision 8804)
+++ ccache.c	(copie de travail)
@@ -935,15 +934,23 @@
 		case 'F':
 			check_cache_dir();
 			v = atoi(optarg);
-			stats_set_limits(v, -1);
-			printf("Set cache file limit to %u\n", (unsigned)v);
+			if (stats_set_limits(v, -1) == 0) {
+				printf("Set cache file limit to %u\n", (unsigned)v);
+			} else {
+				printf("Could not set cache file limit.\n");
+				exit(1);
+			}
 			break;
 
 		case 'M':
 			check_cache_dir();
 			v = value_units(optarg);
-			stats_set_limits(-1, v);
-			printf("Set cache size limit to %uk\n", (unsigned)v);
+			if (stats_set_limits(-1, v) == 0) {
+				printf("Set cache size limit to %uk\n", (unsigned)v);
+			} else {
+				printf("Could not set cache size limit.\n");
+				exit(1);
+			}
 			break;
 
 		default:
--- ccache.h	(révision 8804)
+++ ccache.h	(copie de travail)
@@ -101,7 +101,7 @@
 void stats_summary(void);
 void stats_tocache(size_t size);
 void stats_read(const char *stats_file, unsigned counters[STATS_END]);
-void stats_set_limits(long maxfiles, long maxsize);
+int stats_set_limits(long maxfiles, long maxsize);
 size_t value_units(const char *s);
 void display_size(unsigned v);
 void stats_set_sizes(const char *dir, size_t num_files, size_t total_size);