Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fb48919

Browse files
committedMar 13, 2025·
fs/fcb: Address review comments
1 parent c3e7c19 commit fb48919

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
 

‎fs/fcb/include/fcb/fcb.h

+8
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,19 @@ int fcb_append_to_scratch(struct fcb *);
216216

217217
/**
218218
* How many sectors are unused.
219+
*
220+
* @param fcb - fcb to check
221+
* @return number of free sectors if successful,
222+
* negative value on error
219223
*/
220224
int fcb_free_sector_cnt(struct fcb *fcb);
221225

222226
/**
223227
* Whether FCB has any data.
228+
*
229+
* @param fcb - fcb to check
230+
* @return 1 if FCB is empty, 0 if FCB has data,
231+
* negative value on error
224232
*/
225233
int fcb_is_empty(struct fcb *fcb);
226234

‎fs/fcb/src/fcb.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ fcb_free_sector_cnt(struct fcb *fcb)
130130
return i;
131131
}
132132

133+
int
134+
fcb_is_empty_nolock(struct fcb *fcb)
135+
{
136+
bool ret = false;
137+
138+
ret = (fcb->f_active.fe_area == fcb->f_oldest &&
139+
fcb->f_active.fe_elem_off == sizeof(struct fcb_disk_area));
140+
141+
return ret;
142+
}
143+
133144
int
134145
fcb_is_empty(struct fcb *fcb)
135146
{
@@ -262,13 +273,13 @@ fcb_offset_last_n(struct fcb *fcb, uint8_t entries,
262273

263274
i = 0;
264275
memset(&loc, 0, sizeof(loc));
265-
while (!fcb_getnext(fcb, &loc)) {
276+
while (!fcb_getnext_nolock(fcb, &loc)) {
266277
if (i == 0) {
267278
/* Start from the beginning of fcb entries */
268279
*last_n_entry = loc;
269280
} else if (i > (entries - 1)) {
270281
/* Update last_n_entry after n entries and keep updating */
271-
fcb_getnext(fcb, last_n_entry);
282+
fcb_getnext_nolock(fcb, last_n_entry);
272283
}
273284
i++;
274285
}
@@ -293,7 +304,7 @@ fcb_clear(struct fcb *fcb)
293304
return FCB_ERR_ARGS;
294305
}
295306

296-
while (!fcb_is_empty(fcb)) {
307+
while (!fcb_is_empty_nolock(fcb)) {
297308
rc = fcb_rotate(fcb);
298309
if (rc) {
299310
break;

0 commit comments

Comments
 (0)
Please sign in to comment.