Ticket #293: eval.c.patch

File eval.c.patch, 2.0 KB (added by strauman, on Dec 3, 2006 at 1:31:12 PM)

eval.c.patch

Line 
1Index: eval.c
2===================================================================
3RCS file: /afs/slac/g/spear/cvsrep/rtems/src/c/src/lib/libc/eval.c,v
4retrieving revision 1.1.1.2
5diff -c -r1.1.1.2 eval.c
6*** eval.c      7 Mar 2002 01:53:48 -0000       1.1.1.2
7--- eval.c      23 Oct 2002 22:03:48 -0000
8***************
9*** 60,76 ****
10 
11    if ( (result == 0) && follow_link ) {
12 
13!     if ( !pathloc->ops->node_type_h )
14        rtems_set_errno_and_return_minus_one( ENOTSUP );
15 
16      type = (*pathloc->ops->node_type_h)( pathloc );
17 
18      if ( ( type == RTEMS_FILESYSTEM_HARD_LINK ) ||
19           ( type == RTEMS_FILESYSTEM_SYM_LINK ) ) {
20 
21!         if ( !pathloc->ops->eval_link_h )
22            rtems_set_errno_and_return_minus_one( ENOTSUP );
23 
24           result =  (*pathloc->ops->eval_link_h)( pathloc, flags );
25   
26      }
27--- 60,93 ----
28 
29    if ( (result == 0) && follow_link ) {
30 
31!     if ( !pathloc->ops->node_type_h ) {
32!         rtems_filesystem_freenode(pathloc);
33        rtems_set_errno_and_return_minus_one( ENOTSUP );
34+       }
35 
36      type = (*pathloc->ops->node_type_h)( pathloc );
37 
38      if ( ( type == RTEMS_FILESYSTEM_HARD_LINK ) ||
39           ( type == RTEMS_FILESYSTEM_SYM_LINK ) ) {
40 
41!         if ( !pathloc->ops->eval_link_h ) {
42!             rtems_filesystem_freenode(pathloc);
43            rtems_set_errno_and_return_minus_one( ENOTSUP );
44+               }
45 
46+               /* what to do with the valid node pathloc points to
47+                * if eval_link_h() fails?
48+                * Let the FS implementation deal with this case. It
49+                * should probably free pathloc in either case:
50+                *   - if the link evaluation fails, it must free the
51+                *     original (valid) pathloc because we are going
52+                *     to return -1 and hence the FS generics won't
53+                *     cleanup pathloc
54+                *   - if the link evaluation is successful, the updated
55+                *     pathloc will be passed up (and eventually released).
56+                *     Hence, the (valid) original node that we submit to
57+                *     eval_link_h() should be released by the handler.
58+                */
59           result =  (*pathloc->ops->eval_link_h)( pathloc, flags );
60   
61      }