Skip to content

Commit 8788f39

Browse files
authored
Merge branch 'RT-Thread:master' into master
2 parents c0b86f9 + ea5e1ca commit 8788f39

60 files changed

Lines changed: 6163 additions & 3538 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/dfs/dfs_v1/filesystems/9pfs/dfs_9pfs.c

Lines changed: 78 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
#define ORCLOSE 64 /* or'ed in, remove on close */
3232
#define OAPPEND 128 /* or'ed in, append */
3333

34-
#define NOTAG ((rt_uint16_t)~0)
35-
#define NOFID ((rt_uint32_t)~0)
36-
#define TAG 1
34+
#define NOTAG ((rt_uint16_t)~0)
35+
#define NOFID ((rt_uint32_t)~0)
36+
#define TAG 1
3737

3838
static rt_list_t _protocol_nodes = RT_LIST_OBJECT_INIT(_protocol_nodes);
3939
static struct rt_spinlock _protocol_lock = { 0 };
@@ -45,37 +45,37 @@ static struct rt_spinlock _protocol_lock = { 0 };
4545
#define rt_cpu_to_le8
4646
#endif
4747

48-
#define P9_OF_OPS_GET(width, dir) \
49-
rt_inline rt_uint##width##_t get_##dir##_##value##width##_of( \
50-
struct p9_connection *conn, unsigned idx) \
51-
{ \
52-
rt_uint##width##_t *vp = (void *)&conn->dir##_buffer[idx]; \
53-
return rt_le##width##_to_cpu(*vp); \
54-
}
48+
#define P9_OF_OPS_GET(width, dir) \
49+
rt_inline rt_uint##width##_t get_##dir##_##value##width##_of( \
50+
struct p9_connection *conn, unsigned idx) \
51+
{ \
52+
rt_uint##width##_t *vp = (void *)&conn->dir##_buffer[idx]; \
53+
return rt_le##width##_to_cpu(*vp); \
54+
}
5555

56-
#define P9_OF_OPS_PUT(width, dir) \
57-
rt_inline void put_##dir##_##value##width##_of( \
58-
struct p9_connection *conn, unsigned idx, \
59-
rt_uint##width##_t value) \
60-
{ \
61-
rt_uint##width##_t *vp = (void *)&conn->dir##_buffer[idx]; \
62-
*vp = rt_cpu_to_le##width(value); \
63-
}
56+
#define P9_OF_OPS_PUT(width, dir) \
57+
rt_inline void put_##dir##_##value##width##_of( \
58+
struct p9_connection *conn, unsigned idx, \
59+
rt_uint##width##_t value) \
60+
{ \
61+
rt_uint##width##_t *vp = (void *)&conn->dir##_buffer[idx]; \
62+
*vp = rt_cpu_to_le##width(value); \
63+
}
6464

65-
#define P9_OPS_PUT(width) \
66-
rt_inline rt_off_t put_value##width(struct p9_connection *conn, \
67-
rt_off_t off, rt_uint##width##_t value) \
68-
{ \
69-
((rt_uint##width##_t *)(conn->tx_buffer + off))[0] = \
70-
rt_cpu_to_le##width(value); \
71-
return off + sizeof(value); \
72-
}
65+
#define P9_OPS_PUT(width) \
66+
rt_inline rt_off_t put_value##width(struct p9_connection *conn, \
67+
rt_off_t off, rt_uint##width##_t value) \
68+
{ \
69+
((rt_uint##width##_t *)(conn->tx_buffer + off))[0] = \
70+
rt_cpu_to_le##width(value); \
71+
return off + sizeof(value); \
72+
}
7373

74-
#define P9_OPS_GROUP(width) \
75-
P9_OF_OPS_GET(width, rx) \
76-
P9_OF_OPS_GET(width, tx) \
77-
P9_OF_OPS_PUT(width, rx) \
78-
P9_OF_OPS_PUT(width, tx) \
74+
#define P9_OPS_GROUP(width) \
75+
P9_OF_OPS_GET(width, rx) \
76+
P9_OF_OPS_GET(width, tx) \
77+
P9_OF_OPS_PUT(width, rx) \
78+
P9_OF_OPS_PUT(width, tx) \
7979
P9_OPS_PUT(width)
8080

8181
P9_OPS_GROUP(8)
@@ -88,7 +88,7 @@ P9_OPS_GROUP(64)
8888
#undef P9_OPS_GROUP
8989

9090
rt_inline rt_uint32_t put_header(struct p9_connection *conn,
91-
rt_uint8_t hd, rt_uint16_t tag_flags)
91+
rt_uint8_t hd, rt_uint16_t tag_flags)
9292
{
9393
rt_uint8_t *stack = conn->tx_buffer;
9494

@@ -105,7 +105,7 @@ rt_inline rt_uint32_t put_header(struct p9_connection *conn,
105105
}
106106

107107
rt_inline rt_off_t put_bytes(struct p9_connection *conn, rt_off_t off,
108-
rt_uint8_t *bytes, rt_uint32_t count)
108+
rt_uint8_t *bytes, rt_uint32_t count)
109109
{
110110
rt_uint8_t *stack = conn->tx_buffer + off;
111111

@@ -119,7 +119,7 @@ rt_inline rt_off_t put_bytes(struct p9_connection *conn, rt_off_t off,
119119
}
120120

121121
rt_inline rt_off_t put_string(struct p9_connection *conn, rt_off_t off,
122-
char *string)
122+
char *string)
123123
{
124124
rt_uint32_t len = rt_strlen(string);
125125
rt_uint8_t *stack = conn->tx_buffer + off;
@@ -134,7 +134,7 @@ rt_inline rt_off_t put_string(struct p9_connection *conn, rt_off_t off,
134134
}
135135

136136
struct p9_connection *p9_connection_alloc(struct p9_protocol *p9p,
137-
const char *aname, rt_uint32_t buffer_size)
137+
const char *aname, rt_uint32_t buffer_size)
138138
{
139139
struct p9_connection *conn;
140140

@@ -177,7 +177,7 @@ rt_err_t p9_connection_free(struct p9_connection *conn)
177177
}
178178

179179
int p9_transaction(struct p9_connection *conn,
180-
rt_uint32_t tx_size, rt_uint32_t *out_rx_size)
180+
rt_uint32_t tx_size, rt_uint32_t *out_rx_size)
181181
{
182182
rt_err_t err;
183183
rt_uint32_t rx_size;
@@ -187,7 +187,7 @@ int p9_transaction(struct p9_connection *conn,
187187

188188
rx_size = conn->msg_size;
189189
if ((err = conn->protocol->transport(conn->protocol,
190-
conn->tx_buffer, tx_size, conn->rx_buffer, &rx_size)))
190+
conn->tx_buffer, tx_size, conn->rx_buffer, &rx_size)))
191191
{
192192
return P9_TRANSPORT_ERROR;
193193
}
@@ -201,7 +201,7 @@ int p9_transaction(struct p9_connection *conn,
201201
if (get_rx_value8_of(conn, P9_MSG_ID) == P9_MSG_ERR)
202202
{
203203
rt_uint32_t err_len = rt_min_t(rt_uint32_t, sizeof(conn->error) - 1,
204-
get_rx_value16_of(conn, P9_MSG_ERR_STR_LEN));
204+
get_rx_value16_of(conn, P9_MSG_ERR_STR_LEN));
205205

206206
rt_strncpy(conn->error, (void *)&conn->rx_buffer[P9_MSG_ERR_STR], err_len);
207207

@@ -367,8 +367,7 @@ rt_err_t dfs_9pfs_del_tag(struct p9_protocol *p9p)
367367

368368
static int p9_to_fs_err(int rc)
369369
{
370-
const int p9_err[] =
371-
{
370+
const int p9_err[] = {
372371
[0] = RT_EOK,
373372
[-P9_ERROR] = -EIO,
374373
[-P9_UNKNOWN_VERSION] = -ENOSYS,
@@ -428,10 +427,18 @@ static rt_uint8_t fs_to_p9_flags(rt_uint32_t raw_flags)
428427

429428
switch (raw_flags & 3)
430429
{
431-
case O_RDONLY: flags = OREAD; break;
432-
case O_WRONLY: flags = OWRITE; break;
433-
case O_RDWR: flags = ORDWR; break;
434-
default: RT_ASSERT(0); break;
430+
case O_RDONLY:
431+
flags = OREAD;
432+
break;
433+
case O_WRONLY:
434+
flags = OWRITE;
435+
break;
436+
case O_RDWR:
437+
flags = ORDWR;
438+
break;
439+
default:
440+
RT_ASSERT(0);
441+
break;
435442
}
436443

437444
if (raw_flags & O_TRUNC)
@@ -460,7 +467,7 @@ static char *p9_basename(const char *path)
460467
}
461468

462469
static int p9_walk_path_raw(struct p9_connection *conn, const char *path,
463-
rt_bool_t submode)
470+
rt_bool_t submode)
464471
{
465472
rt_uint32_t size;
466473
const char *split;
@@ -490,7 +497,8 @@ static int p9_walk_path_raw(struct p9_connection *conn, const char *path,
490497
size = put_value32(conn, size, new_fid);
491498
size = put_value16(conn, size, 0); /* Fill later */
492499

493-
do {
500+
do
501+
{
494502
split = strchrnul(path, '/');
495503

496504
len = split - path;
@@ -880,8 +888,8 @@ static int dfs_9pfs_getdents(struct dfs_file *fd, struct dirent *dirp, uint32_t
880888
dirp->d_namlen = get_rx_value16_of(conn, off + P9_MSG_STAT_NAME_LEN);
881889
dirp->d_reclen = (rt_uint16_t)sizeof(struct dirent);
882890
rt_strncpy(dirp->d_name,
883-
(void *)conn->rx_buffer + off + P9_MSG_STAT_NAME,
884-
dirp->d_namlen);
891+
(void *)conn->rx_buffer + off + P9_MSG_STAT_NAME,
892+
dirp->d_namlen);
885893
dirp->d_name[dirp->d_namlen] = '\0';
886894

887895
if (!rt_strcmp(dirp->d_name, ".") || !rt_strcmp(dirp->d_name, ".."))
@@ -908,22 +916,21 @@ static int dfs_9pfs_getdents(struct dfs_file *fd, struct dirent *dirp, uint32_t
908916
return count;
909917
}
910918

911-
static const struct dfs_file_ops _9pfs_fops =
912-
{
913-
.open = dfs_9pfs_open,
914-
.close = dfs_9pfs_close,
915-
.read = dfs_9pfs_read,
916-
.write = dfs_9pfs_write,
917-
.flush = dfs_9pfs_flush,
918-
.lseek = dfs_9pfs_lseek,
919-
.getdents = dfs_9pfs_getdents,
919+
static const struct dfs_file_ops _9pfs_fops = {
920+
.open = dfs_9pfs_open,
921+
.close = dfs_9pfs_close,
922+
.read = dfs_9pfs_read,
923+
.write = dfs_9pfs_write,
924+
.flush = dfs_9pfs_flush,
925+
.lseek = dfs_9pfs_lseek,
926+
.getdents = dfs_9pfs_getdents,
920927
};
921928

922929
static int dfs_9pfs_mount(struct dfs_filesystem *fs,
923-
unsigned long rwflag, const void *data)
930+
unsigned long rwflag, const void *data)
924931
{
925932
rt_ubase_t level;
926-
struct p9_protocol *p9p, *p9p_tmp;
933+
struct p9_protocol *p9p = RT_NULL, *p9p_tmp;
927934
struct p9_connection *conn = RT_NULL;
928935

929936
if (!data)
@@ -1042,7 +1049,7 @@ static int dfs_9pfs_unlink(struct dfs_filesystem *fs, const char *pathname)
10421049
}
10431050

10441051
static int dfs_9pfs_stat(struct dfs_filesystem *fs,
1045-
const char *filename, struct stat *st)
1052+
const char *filename, struct stat *st)
10461053
{
10471054
int rc = 0, fid;
10481055
rt_uint32_t size, mode;
@@ -1133,7 +1140,7 @@ static int dfs_9pfs_stat(struct dfs_filesystem *fs,
11331140
}
11341141

11351142
static int dfs_9pfs_rename(struct dfs_filesystem *fs,
1136-
const char *oldpath, const char *newpath)
1143+
const char *oldpath, const char *newpath)
11371144
{
11381145
int rc = 0, fid;
11391146
rt_uint32_t size;
@@ -1162,20 +1169,19 @@ static int dfs_9pfs_rename(struct dfs_filesystem *fs,
11621169
return p9_to_fs_err(rc);
11631170
}
11641171

1165-
static const struct dfs_filesystem_ops _9pfs =
1166-
{
1167-
.name = "9p",
1168-
.flags = DFS_FS_FLAG_DEFAULT,
1169-
.fops = &_9pfs_fops,
1172+
static const struct dfs_filesystem_ops _9pfs = {
1173+
.name = "9p",
1174+
.flags = DFS_FS_FLAG_DEFAULT,
1175+
.fops = &_9pfs_fops,
11701176

1171-
.mount = dfs_9pfs_mount,
1172-
.unmount = dfs_9pfs_unmount,
1177+
.mount = dfs_9pfs_mount,
1178+
.unmount = dfs_9pfs_unmount,
11731179

1174-
.statfs = dfs_9pfs_statfs,
1180+
.statfs = dfs_9pfs_statfs,
11751181

1176-
.unlink = dfs_9pfs_unlink,
1177-
.stat = dfs_9pfs_stat,
1178-
.rename = dfs_9pfs_rename,
1182+
.unlink = dfs_9pfs_unlink,
1183+
.stat = dfs_9pfs_stat,
1184+
.rename = dfs_9pfs_rename,
11791185
};
11801186

11811187
int dfs_9pfs_init(void)

components/dfs/dfs_v1/filesystems/elmfat/00history.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,33 @@ R0.14b (April 17, 2021)
357357
Fixed some compiler warnings.
358358

359359

360+
361+
R0.15 (November 6, 2022)
362+
Changed user provided synchronization functions in order to completely eliminate the platform dependency from FatFs code.
363+
FF_SYNC_t is removed from the configuration options.
364+
Fixed a potential error in f_mount when FF_FS_REENTRANT.
365+
Fixed file lock control FF_FS_LOCK is not mutal excluded when FF_FS_REENTRANT && FF_VOLUMES > 1 is true.
366+
Fixed f_mkfs() creates broken exFAT volume when the size of volume is >= 2^32 sectors.
367+
Fixed string functions cannot write the unicode characters not in BMP when FF_LFN_UNICODE == 2 (UTF-8).
368+
Fixed a compatibility issue in identification of GPT header.
369+
370+
371+
372+
R0.15a (November 22, 2024)
373+
Fixed a complie error when FF_FS_LOCK != 0.
374+
Fixed a potential issue when work FatFs concurrency with FF_FS_REENTRANT, FF_VOLUMES >= 2 and FF_FS_LOCK > 0.
375+
Made f_setlabel() accept a volume label in Unix style volume ID when FF_STR_VOLUME_ID == 2.
376+
Made FatFs update PercInUse field in exFAT VBR. (A preceding f_getfree() is needed for the accuracy)
377+
378+
379+
380+
R0.15b (June 21, 2025)
381+
Added support for timestamp of created time. (FF_FS_CRTIME)
382+
Fixed FatFs fails to load the FsInfo in FAT32 volumes and the f_getfree always be forced a full FAT scan which takes a long time. (appeared at R0.15a)
383+
384+
385+
386+
R0.16 (July 22, 2025)
387+
Removed a long-pending limitation that f_getcwd and double-dot .. in the path name did not work on the exFAT volume.
388+
Fixed f_readdir cannot detect end of directory and it leads the application process into infinite loop. (appeared at R0.15b)
389+
Fixed dot names with terminating separator or duplicated separator are rejected when LFN is not enabled.

components/dfs/dfs_v1/filesystems/elmfat/00readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FatFs Module Source Files R0.14b
1+
FatFs Module Source Files R0.16
22

33

44
FILES

components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -997,41 +997,41 @@ DWORD get_fattime(void)
997997
}
998998

999999
#if FF_FS_REENTRANT
1000-
int ff_cre_syncobj(BYTE drv, FF_SYNC_t *m)
1000+
static rt_mutex_t Mutex[FF_VOLUMES + 1];
1001+
1002+
int ff_mutex_create (int vol)
10011003
{
10021004
char name[8];
10031005
rt_mutex_t mutex;
10041006

1005-
rt_snprintf(name, sizeof(name), "fat%d", drv);
1007+
rt_snprintf(name, sizeof(name), "fat%d", vol);
10061008
mutex = rt_mutex_create(name, RT_IPC_FLAG_PRIO);
10071009
if (mutex != RT_NULL)
10081010
{
1009-
*m = mutex;
1011+
Mutex[vol] = mutex;
10101012
return RT_TRUE;
10111013
}
10121014

10131015
return RT_FALSE;
10141016
}
10151017

1016-
int ff_del_syncobj(FF_SYNC_t m)
1018+
void ff_mutex_delete (int vol)
10171019
{
1018-
if (m != RT_NULL)
1019-
rt_mutex_delete(m);
1020-
1021-
return RT_TRUE;
1020+
if (Mutex[vol] != RT_NULL)
1021+
rt_mutex_delete(Mutex[vol]);
10221022
}
10231023

1024-
int ff_req_grant(FF_SYNC_t m)
1024+
int ff_mutex_take (int vol)
10251025
{
1026-
if (rt_mutex_take(m, FF_FS_TIMEOUT) == RT_EOK)
1026+
if (rt_mutex_take(Mutex[vol], FF_FS_TIMEOUT) == RT_EOK)
10271027
return RT_TRUE;
10281028

10291029
return RT_FALSE;
10301030
}
10311031

1032-
void ff_rel_grant(FF_SYNC_t m)
1032+
void ff_mutex_give (int vol)
10331033
{
1034-
rt_mutex_release(m);
1034+
rt_mutex_release(Mutex[vol]);
10351035
}
10361036

10371037
#endif

0 commit comments

Comments
 (0)