Subversion Repositories HelenOS

Rev

Rev 2404 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2404 Rev 2435
Line 30... Line 30...
30
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
 */
34
 */
35
 
-
 
36
 
35
 
37
/* This file contains the code for performing four system calls relating to
-
 
38
 * status and directories.
36
/** @addtogroup FileSystemImpl
-
 
37
* @{
39
 */
38
*/
40
 
39
 
41
/* Methods:
40
/**
42
 * do_chdir:  perform the CHDIR system call
41
 * @file    stadir.c
43
 * do_stat:   perform the STAT system call
42
 * @brief   This file contains the code for performing four system calls relating to
44
 * do_fstat:  perform the FSTAT system call
43
 *        status and directories.
45
 */
44
 */
46
 
45
 
47
 
46
 
48
#include "fs.h"
47
#include "fs.h"
49
#include "stat.h"
48
#include "stat.h"
Line 53... Line 52...
53
#include "param.h"
52
#include "param.h"
54
 
53
 
55
 
54
 
56
static int change(inode_t **iip, char *name_ptr, int len);
55
static int change(inode_t **iip, char *name_ptr, int len);
57
static int stat_inode(inode_t *rip, filp_t *fil_ptr, char *user_addr);
56
static int stat_inode(inode_t *rip, filp_t *fil_ptr, char *user_addr);
58
   
57
 
-
 
58
/**
-
 
59
 * Perform the CHDIR system call
-
 
60
 */
59
int do_chdir()
61
int do_chdir()
60
{
62
{
61
     
63
     
62
    /* Perform the chdir(file_name) system call */
64
    /* Perform the chdir(file_name) system call */
63
    int r;
65
    int r;
64
 
66
 
65
    r = change(&fp->fp_workdir, file_name, strlen(file_name)+1);
67
    r = change(&fp->fp_workdir, file_name, strlen(file_name)+1);
66
   
68
   
67
    return r;
69
    return r;
68
}
70
}
-
 
71
 
-
 
72
/**
-
 
73
 * Execute changing the current directory
69
       
74
 */    
70
int change(inode_t **iip, char *name_ptr, int len)
75
int change(inode_t **iip, char *name_ptr, int len)
71
{
76
{
72
   
77
   
73
    /*
78
    /*
74
     * iip:     pointer to the inode pointer for the dir
79
     * iip:     pointer to the inode pointer for the dir
Line 104... Line 109...
104
    put_inode(*iip);    /* release the old directory */
109
    put_inode(*iip);    /* release the old directory */
105
    *iip = rip;     /* acquire the new one */
110
    *iip = rip;     /* acquire the new one */
106
 
111
 
107
    return OK;
112
    return OK;
108
}
113
}
109
   
114
 
-
 
115
/**
-
 
116
 * Perform the STAT system call
-
 
117
 */
110
int do_stat()
118
int do_stat()
111
{
119
{
112
   
120
   
113
    /* Perform the stat(name, buf) system call. */
121
    /* Perform the stat(name, buf) system call. */
114
   
122
   
Line 128... Line 136...
128
    r = stat_inode(rip, NIL_FILP, fp->buffer); /* actually do the work.*/
136
    r = stat_inode(rip, NIL_FILP, fp->buffer); /* actually do the work.*/
129
    put_inode(rip);     /* release the inode */
137
    put_inode(rip);     /* release the inode */
130
     
138
     
131
    return r;
139
    return r;
132
}
140
}
133
   
141
 
-
 
142
/**
-
 
143
 * Perform the FSTAT system call
-
 
144
 */
134
int do_fstat()
145
int do_fstat()
135
{
146
{
136
   
147
   
137
    /* Perform the fstat(fd, buf) system call. */
148
    /* Perform the fstat(fd, buf) system call. */
138
   
149
   
Line 146... Line 157...
146
    if (rfilp->filp_ino == NIL_INODE)
157
    if (rfilp->filp_ino == NIL_INODE)
147
        return FS_ENOENT;
158
        return FS_ENOENT;
148
     
159
     
149
    return(stat_inode(rfilp->filp_ino, NIL_FILP, fp->buffer));
160
    return(stat_inode(rfilp->filp_ino, NIL_FILP, fp->buffer));
150
}
161
}
151
   
162
 
-
 
163
/**
-
 
164
 * Execute the actual STAT operation
-
 
165
 */
152
int stat_inode(register inode_t *rip, filp_t *fil_ptr, char *user_addr)
166
int stat_inode(register inode_t *rip, filp_t *fil_ptr, char *user_addr)
153
{  
167
{  
154
   
168
   
155
    /*
169
    /*
156
     * rip:         pointer to inode to stat
170
     * rip:         pointer to inode to stat
Line 172... Line 186...
172
    memcpy(user_addr, &statbuf, sizeof(statbuf));
186
    memcpy(user_addr, &statbuf, sizeof(statbuf));
173
     
187
     
174
    return OK;
188
    return OK;
175
}
189
}
176
 
190
 
-
 
191
 
-
 
192
/**
-
 
193
 * }
-
 
194
 */
-
 
195