andrzej-kaczmarek commented on a change in pull request #1149: sys/log: Add log 
storage usage tracking and watermarking
URL: https://github.com/apache/mynewt-core/pull/1149#discussion_r194833582
 
 

 ##########
 File path: sys/log/full/src/log_fcb.c
 ##########
 @@ -235,6 +253,126 @@ log_fcb_flush(struct log *log)
     return fcb_clear(&((struct fcb_log *)log->l_arg)->fl_fcb);
 }
 
+static int
+log_fcb_registered(struct log *log)
+{
+#if MYNEWT_VAL(LOG_STORAGE_WATERMARK)
+    struct fcb_log *fl;
+    struct fcb *fcb;
+    struct fcb_entry loc;
+
+    fl = (struct fcb_log *)log->l_arg;
+    fcb = &fl->fl_fcb;
+
+    /* Set watermark to first element */
+    memset(&loc, 0, sizeof(loc));
+    if (fcb_getnext(fcb, &loc)) {
+        fl->fl_watermark_off = loc.fe_area->fa_off + loc.fe_elem_off;
+    } else {
+        fl->fl_watermark_off = fcb->f_oldest->fa_off;
+    }
+#endif
+    return 0;
+}
+
+#if MYNEWT_VAL(LOG_STORAGE_INFO)
+static int
+log_fcb_storage_info(struct log *log, struct log_storage_info *info)
+{
+    struct fcb_log *fl;
+    struct fcb *fcb;
+    struct flash_area *fa;
+    uint32_t el_min;
+    uint32_t el_max;
+    uint32_t fa_min;
+    uint32_t fa_max;
+    uint32_t fa_size;
+    uint32_t fa_used;
+
+    fl = (struct fcb_log *)log->l_arg;
+    fcb = &fl->fl_fcb;
+
+    /*
+     * Calculate location of 1st entry.
+     * We assume 1st log entry starts at beginning of oldest sector in FCB.
+     * This is because even if 1st entry is in the middle of sector (is this
+     * even possible?) we will never use free space before it thus that space
+     * can be also considered used.
+     */
+    el_min = fcb->f_oldest->fa_off;
 
 Review comment:
   yeah, I think it should be. I'll fix it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to