+static off_t getused_size; /* result of getused() */
+
+/*!
+ nftw callback for getused()
+ */
+static int getused_stat(const char *path,
+ const struct stat *statp,
+ int tflag,
+ struct FTW *ftw)
+{
+ if (tflag == FTW_F) {
+ getused_size += statp->st_size;
+ }
+ return 0;
+}
+
+/*!
+ * Calculate used size of a volume with nftw
+ *
+ * 1) Check if the volume has been modified or the v_mtime has not
+ * yet been set
+ * 2) Call nftw if yes
+ *
+ * @param vol (r) volume to calculate
+ */
+static int getused(const struct vol *vol)
+{
+ static time_t vol_mtime = 0;
+ int ret = 0;
+
+ if (!vol->v_mtime || (vol_mtime < vol->v_mtime)) { /* 1 */
+ vol_mtime = vol->v_mtime;
+ getused_size = 0;
+ ret = nftw(vol->v_path, getused_stat, NULL, 20, FTW_PHYS); /* 2 */
+ } else {
+ LOG(log_note, logtype_afpd, "volparams: cached used: %" PRIu64 " bytes",
+ getused_size);
+
+ }
+
+exit:
+ return ret;
+}
+