<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=GB2312" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi:<br>
<ol>
<li>
<pre>rtems_libio_is_valid_perms always returns non-zero value,
so I can't catch why it's called in IMFS_evaluate_permission and IMFS_eval_path.
#define RTEMS_LIBIO_PERMS_RWX S_IRWXO
/*
* Verifies that the permission flag is valid.
*/
#define rtems_libio_is_valid_perms( _perm ) \
(~ ((~RTEMS_LIBIO_PERMS_RWX) & _perm ))
</pre>
</li>
<li>Why isn't there a semaphore and reference count to protect IMFS
nodes like dosfs?<br>
Let's suppose / and /mem are IMFS_DIRECTORY nodes, and<br>
/mem/file is an IMFS_MEMORY_FILE node. Then I can delete<br>
/mem/file while it's still in open progress. To prove this, you can
create two task:<br>
<br>
rtems_task imfs_reader(rtems_task_argument argument)<br>
{<br>
int open_status, stat_status;<br>
struct stat stat_buf;<br>
rtems_id tid;<br>
<br>
rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );<br>
printf( "imfs_reader task was invoked with argument (%d) "<br>
"and has id of 0x%x\n", argument, tid );<br>
<br>
while(1){<br>
open_status = open("/dev/test", 0);<br>
sleep(2+argument);<br>
stat_status = stat("/dev/test", &stat_buf);<br>
if(open_status>=0 && stat_status==-1){<br>
printf("file deleted while still opened\n", argument);<br>
Print_time();<br>
exit(0);<br>
}<br>
close(open_status);<br>
}<br>
}<br>
<br>
rtems_task imfs_writer(rtems_task_argument argument)<br>
{<br>
rtems_id tid;<br>
<br>
rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );<br>
printf( "imfs_writer task was invoked with argument (%d) "<br>
"and has id of 0x%x\n", argument, tid );<br>
<br>
while(1){<br>
mknod("/dev/test", 0777|S_IFCHR, 0);<br>
sleep(2+argument);<br>
unlink("/dev/test");<br>
sleep(2+argument);<br>
}<br>
}<br>
<br>
After about 4 seconds, you can see "file deleted while still opened" on
the screen.<br>
<br>
<br>
</li>
<li>imfs_dir_close doesn't check the st_nlink member of an IMFS
directory node.<br>
So such a scenario will cause memory leak:<br>
<ol type="i">
<li>suppose /emptydir is an empty IMFS directory</li>
</ol>
<ol start="2" type="i">
<li>dirp = opendir("/emptydir");<br>
rmdir("/emptydir");<br>
closedir(dirp);</li>
<li>After rmdir calls imfs_dir_rmnod, the IMFS node of /emptydir
has been<br>
Chain_Extract from the IMFS name tree, but can't be freed as a result of<br>
opendir. Because imfs_dir_close doesn't do any check, this IMFS node<br>
will never be freed.<br>
</li>
</ol>
</li>
</ol>
<br>
Question No 2 and 3 are very obvious, I'm very confused why you guys
remain the code<br>
like that, so I guess you may think it's the application-user's
responsiblity to do<br>
the synchronization, but why dosfs does the effort while IMFS doesn't.<br>
<br>
Thank you very much for bringing us such a good open-source real-time
os to the world:)))<br>
<br>
<br>
best wishes from shizheng, University of Science and Technology of China<br>
<br>
</body>
</html>