+#if 0
+
+struct mountpoint {
+ const char *path;
+ int kbytes;
+ int files;
+};
+
+struct mptree {
+ Id sibling;
+ Id child;
+ const char *comp;
+ int compl;
+ Id mountpoint;
+};
+
+struct cbdata {
+ struct mountpoint *mps;
+ Id *dirmap;
+ int nmap;
+};
+
+static int
+pool_fill_DU_add_cb(void *data, Solvable *s, Id key, const char *str)
+{
+ struct cbdata *cbdata = data;
+ Id mp, dirnum, kbytes, files;
+
+ dp = data_read_id(dp, &dirnum);
+ dp = data_read_id(dp, &kbytes);
+ data_read_id(dp, &files);
+ if (dirnum < 0 || dirnum > cbdata->nmap)
+ return 0;
+ mp = cbdata->dirmap[dirnum];
+ if (mp >= 0)
+ {
+ cbdata->mps[mp].kbytes += kbytes;
+ cbdata->mps[mp].files += files;
+ }
+ return 0;
+}
+
+static int
+pool_fill_DU_sub_cb(void *data, Solvable *s, Id key, const char *str)
+{
+ struct cbdata *cbdata = data;
+ Id mp, dirnum, kbytes, files;
+
+ dp = data_read_id(dp, &dirnum);
+ dp = data_read_id(dp, &kbytes);
+ data_read_id(dp, &files);
+ if (dirnum < 0 || dirnum > cbdata->nmap)
+ return 0;
+ mp = cbdata->dirmap[dirnum];
+ if (mp >= 0)
+ {
+ cbdata->mps[mp].kbytes -= kbytes;
+ cbdata->mps[mp].files -= files;
+ }
+ return 0;
+}
+
+static void
+propagate_mountpoints(struct mptree *mptree, int pos, Id mountpoint)
+{
+ int i;
+ if (mptree[pos].mountpoint == -1)
+ mptree[pos].mountpoint = mountpoint;
+ else
+ mountpoint = mptree[pos].mountpoint;
+ for (i = mptree[pos].child; i; i = mptree[i].sibling)
+ propagate_mountpoints(mptree, i, mountpoint);
+}
+
+void
+pool_fill_DU(Pool *pool, struct mountpoint *mps, int nmps)
+{
+ char *path, *p;
+ Id *dirmap;
+ struct mptree *mptree;
+ int nmptree;
+ int pos;
+ int mp;
+
+ struct matchdata md;
+ struct cbdata cbdata;
+
+ memset(&md, 0, sizeof(md));
+ md.pool = 0;
+ md.matchstr = 0;
+ md.flags = 0;
+ md.callback = 0;
+ md.callback_data = &cbdata
+
+ cbdata.mps = mps;
+ cbdata.dirmap = 0;
+ cbdata.nmap = 0;
+
+ mptree = sat_malloc2(16, sizeof(mptree));
+
+ /* our root node */
+ mptree[0].sibling = 0;
+ mptree[0].child = 0;
+ mptree[0].comp = 0;
+ mptree[0].compl = 0;
+ mptree[0].mountpoint = -1;
+ nmptree = 1;
+
+ /* create component tree */
+ for (mp = 0; mp < nmps; mp++)
+ {
+ pos = 0;
+ path = mps[mp].path;
+ while(*path == '/')
+ path++;
+ while (*path)
+ {
+ if ((p = strchr('/', path)) == 0)
+ {
+ comp = path;
+ compl = strlen(comp);
+ path += compl;
+ }
+ else
+ {
+ comp = path;
+ compl = p - path;
+ path = p + 1;
+ while(*path == '/')
+ path++;
+ }
+ for (i = mptree[pos].child; i; i = mptree[i].sibling)
+ if (mptree[i].compl == compl && !strncmp(mptree[i].comp, comp, compl))
+ break;
+ if (!i)
+ {
+ /* create new node */
+ if ((nmptree & 15) == 0)
+ mptree = sat_realloc2(mptree, nmptree + 16, sizeof(mptree));
+ i = nmptree++;
+ mptree[i].sibling = mptree[pos].child;
+ mptree[i].child = 0;
+ mptree[i].comp = comp;
+ mptree[i].compl = compl;
+ mptree[i].mountpoint = -1;
+ mptree[pos].child = i;
+ }
+ pos = i;
+ }
+ mptree[pos].mountpoint = mp;
+ }
+ propagate_mountpoints(mptree, 0, mptree[0].mountpoint);
+
+ for_all_repos
+ {
+ for_all_repodatas_containing_DU
+ {
+ dirmap = xcalloc2(data->ndirs, sizeof(Id));
+ dirnum = 0;
+ for (;;)
+ {
+ parent = readid();
+ mp = parent ? dirmap[parent] : 0;
+ while (id = readid())
+ {
+ if (mp < 0)
+ {
+ /* unconnected */
+ dirmap[dirnum++] = mp;
+ continue;
+ }
+ if (!mptree[mp].child)
+ {
+ dirmap[dirnum++] = -mp;
+ continue;
+ }
+ comp = id2str(pool, id);
+ compl = strlen(comp);
+ for (i = mptree[mp].child; i; i = mptree[i].sibling)
+ if (mptree[i].compl == compl && !strncmp(mptree[i].comp, comp, compl))
+ break;
+ dirmap[dirnum++] = i ? i : -mp;
+ }
+ }
+ for (i = 0; i < dirnum; i++)
+ {
+ mp = dirmap[i];
+ dirmap[i] = mptree[mp > 0 ? mp : -mp].mountpoint;
+ }
+ cbdata.nmap = dirnum;
+ cbdata.dirmap = dirmap;
+
+ md.callback = pool_fill_DU_add_cb;
+ for_solvables_to_be_installed()
+ {
+ if (p < data->start || p >= data->end)
+ continue;
+ repodata_search(data, p - data->start, SOLVABLE_DUDATA, &md);
+ }
+ md.callback = pool_fill_DU_sub_cb;
+ for_solvables_to_be_erased()
+ {
+ if (p < data->start || p >= data->end)
+ continue;
+ repodata_search(data, p - data->start, SOLVABLE_DUDATA, &md);
+ }
+
+ cbdata.dirmap = 0;
+ cbdata.nmap = 0;
+ sat_free(dirmap);
+ }
+ }
+}
+
+#endif
+