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
/** @addtogroup FileSystemImpl
-
 
37
* @{
-
 
38
*/
-
 
39
 
-
 
40
/**
-
 
41
 * @file    utility.c
-
 
42
 * @brief   This is the master header for fs.  It includes some other files
-
 
43
*         and defines the principal constants.
-
 
44
*/
35
 
45
 
36
 
46
 
37
/* This file contains a few general purpose utility routines. */
47
/* This file contains a few general purpose utility routines. */
38
 
48
 
39
/* Methods:
-
 
40
 * fetch_name:  go get a path name from user space
-
 
41
 * no_sys:      reject a system call that FS does not handle
-
 
42
 * conv2:       does byte swapping on a 16-bit int
-
 
43
 * conv4:       does byte swapping on a 32-bit long
-
 
44
 * fs_strncmp:  same like strncmp
-
 
45
 */
-
 
46
 
-
 
47
 
-
 
48
#include <unistd.h>
49
#include <unistd.h>
49
#include "fs.h"
50
#include "fs.h"
50
#include "block.h"
51
#include "block.h"
51
#include "file.h"
52
#include "file.h"
52
#include "fproc.h"
53
#include "fproc.h"
53
#include "inode.h"
54
#include "inode.h"
54
 
55
 
-
 
56
/**
-
 
57
 * Go get a path name from user space
55
 
58
 */
56
int fetch_name(char* path, int len)
59
int fetch_name(char* path, int len)
57
{
60
{
58
   
61
   
59
    /* Go get path and put it in 'user_path' */
62
    /* Go get path and put it in 'user_path' */
60
 
63
 
Line 76... Line 79...
76
    do { *rpu++ = *rpm++;
79
    do { *rpu++ = *rpm++;
77
        } while (--len);
80
        } while (--len);
78
     
81
     
79
    return OK;
82
    return OK;
80
}
83
}
81
   
84
 
-
 
85
/**
-
 
86
 * Reject a system call that FS does not handle
-
 
87
 */
82
int no_sys()
88
int no_sys()
83
{
89
{
84
   
90
   
85
    /* Somebody has used an illegal system call number */
91
    /* Somebody has used an illegal system call number */
86
         
92
         
87
    print_console("FS_NOSYS called, illegal system call number!\n");
93
    print_console("FS_NOSYS called, illegal system call number!\n");
88
   
94
   
89
    return FS_EINVAL;
95
    re\turn FS_EINVAL;
90
}
96
}
91
   
97
 
-
 
98
/**
-
 
99
 * Does byte swapping on a 16-bit int
-
 
100
 */
92
unsigned conv2(int norm, int w)
101
unsigned conv2(int norm, int w)
93
{
102
{
94
   
103
   
95
    /* Possibly swap a 16-bit word between 8086 and 68000 byte order. */
104
    /* Possibly swap a 16-bit word between 8086 and 68000 byte order. */
96
 
105
 
Line 98... Line 107...
98
        return((unsigned) w & 0xFFFF);
107
        return((unsigned) w & 0xFFFF);
99
       
108
       
100
    return(((w&BYTE) << 8) | ( (w>>8) & BYTE));
109
    return(((w&BYTE) << 8) | ( (w>>8) & BYTE));
101
}
110
}
102
 
111
 
-
 
112
/**
-
 
113
 * Does byte swapping on a 32-bit long
-
 
114
 */
103
long conv4(int norm, long x)
115
long conv4(int norm, long x)
104
{
116
{
105
   
117
   
106
    /* Possibly swap a 32-bit long between 8086 and 68000 byte order. */
118
    /* Possibly swap a 32-bit long between 8086 and 68000 byte order. */
107
   
119
   
Line 116... Line 128...
116
    l = ((long) lo <<16) | hi;
128
    l = ((long) lo <<16) | hi;
117
     
129
     
118
    return l;
130
    return l;
119
}
131
}
120
 
132
 
-
 
133
/**
-
 
134
 * Same like strncmp
-
 
135
 */
121
int fs_strncmp(const char *src, const char *dst, size_t len)
136
int fs_strncmp(const char *src, const char *dst, size_t len)
122
{
137
{
123
   
138
   
124
    int i, src_len, dst_len;
139
    int i, src_len, dst_len;
125
       
140
       
Line 142... Line 157...
142
            return -1;
157
            return -1;
143
    }
158
    }
144
 
159
 
145
    return 0;
160
    return 0;
146
}
161
}
-
 
162
 
-
 
163
/**
-
 
164
 * }
-
 
165
 */
-
 
166