summaryrefslogtreecommitdiffstats
path: root/package/opkg/patches/003-fs_overlay_support.patch
blob: c746cc3e6ce0a57eed85f55882e5a3ac2914345d (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
This patch adds a new configuration option (overlay_root) specifying 
what mount point opkg should check for available storage space.

Signed-off-by: Nicolas Thill <nico@openwrt.org>


--- a/libopkg/opkg_conf.c
+++ b/libopkg/opkg_conf.c
@@ -64,6 +64,7 @@ int opkg_init_options_array(const opkg_c
 	  { "offline_root", OPKG_OPT_TYPE_STRING, &conf->offline_root },
 	  { "offline_root_post_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_post_script_cmd },
 	  { "offline_root_pre_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_pre_script_cmd },
+	  { "overlay_root", OPKG_OPT_TYPE_STRING, &conf->overlay_root },
 	  { "proxy_passwd", OPKG_OPT_TYPE_STRING, &conf->proxy_passwd },
 	  { "proxy_user", OPKG_OPT_TYPE_STRING, &conf->proxy_user },
 	  { "query-all", OPKG_OPT_TYPE_BOOL, &conf->query_all },
--- a/libopkg/opkg_conf.h
+++ b/libopkg/opkg_conf.h
@@ -67,6 +67,7 @@ struct opkg_conf
      char *offline_root;
      char *offline_root_pre_script_cmd;
      char *offline_root_post_script_cmd;
+     char *overlay_root;
      int query_all;
      int verbosity;
      int noaction;
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -524,10 +524,13 @@ static int verify_pkg_installable(opkg_c
      *    my diddling with the .opk file size below isn't going to cut it.
      * 3) return a proper error code instead of 1
      */
-     int comp_size, blocks_available;
-    
+     int comp_size, blocks_available = -1;
+
      if (!conf->force_space && pkg->installed_size != NULL) {
-	  blocks_available = get_available_blocks(conf->default_dest->root_dir);
+          if (conf->overlay_root != NULL)
+               blocks_available = get_available_blocks(conf->overlay_root);
+          if (blocks_available < 0)
+               blocks_available = get_available_blocks(conf->default_dest->root_dir);
 
 	  comp_size = strtoul(pkg->installed_size, NULL, 0);
 	  /* round up a blocks count without doing fancy-but-slow casting jazz */ 
--- a/libopkg/opkg_utils.c
+++ b/libopkg/opkg_utils.c
@@ -30,10 +30,8 @@ int get_available_blocks(char * filesyst
 {
      struct statfs sfs;
 
-     if(statfs(filesystem, &sfs)){
-	  fprintf(stderr, "bad statfs\n");
-	  return 0;
-     }
+     if(statfs(filesystem, &sfs))
+	  return -1;
      /*    fprintf(stderr, "reported fs type %x\n", sfs.f_type); */
      return ((sfs.f_bavail * sfs.f_bsize) / 1024);
 }