xiaoxiang781216 commented on code in PR #3893:
URL: https://github.com/apache/nuttx-apps/pull/3893#discussion_r4339268859


##########
netutils/wifibridge/wifibridge.c:
##########
@@ -346,3 +409,185 @@ int wifibridge_status(FAR const struct 
wifibridge_config_s *config,
   close(sock);
   return OK;
 }
+
+#ifdef CONFIG_NETUTILS_WIFIBRIDGE_PERSIST
+
+/****************************************************************************
+ * Name: wifibridge_record_crc
+ *
+ * Description:
+ *   CRC-32 of the record after the CRC field.
+ *
+ ****************************************************************************/
+
+static uint32_t wifibridge_record_crc(
+                              FAR const struct wifibridge_record_s *record)
+{
+  return crc32((FAR const uint8_t *)&record->version,
+               sizeof(*record) - offsetof(struct wifibridge_record_s,
+                                          version));
+}
+
+/****************************************************************************
+ * Name: wifibridge_record_io
+ *
+ * Description:
+ *   Read or write the record at the start of the storage.
+ *
+ ****************************************************************************/
+
+static int wifibridge_record_io(FAR struct wifibridge_record_s *record,
+                                bool write)
+{
+  ssize_t nbytes;
+  int ret = OK;
+  int fd;
+
+  fd = open(CONFIG_NETUTILS_WIFIBRIDGE_STORAGE,
+            write ? O_RDWR | O_CREAT : O_RDONLY, 0600);
+  if (fd < 0)
+    {
+      return -errno;
+    }
+
+  if (write)
+    {
+      nbytes = pwrite(fd, record, sizeof(*record), 0);

Review Comment:
   write



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to