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
3838static rt_list_t _protocol_nodes = RT_LIST_OBJECT_INIT (_protocol_nodes );
3939static 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
8181P9_OPS_GROUP (8 )
@@ -88,7 +88,7 @@ P9_OPS_GROUP(64)
8888#undef P9_OPS_GROUP
8989
9090rt_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
107107rt_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
121121rt_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
136136struct 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
179179int 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
368368static 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
462469static 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
922929static 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
10441051static 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
11351142static 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
11811187int dfs_9pfs_init (void )
0 commit comments