2 * Creation Date: <2001/05/06 22:27:09 samuel>
3 * Time-stamp: <2003/12/12 02:24:56 samuel>
7 * I/O API used by the filesystem code
9 * Copyright (C) 2001, 2002, 2003 Samuel Rydh (samuel@ibrium.se)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation
18 #include "libopenbios/bindings.h"
20 #include "libc/diskio.h"
24 /************************************************************************/
25 /* functionsions used by the various filesystems */
26 /************************************************************************/
29 get_hfs_vol_name( int fd
, char *buf
, int size
)
32 hfs_mdb_t
*mdb
= (hfs_mdb_t
*)§
;
35 read_io( fd
, sect
, sizeof(sect
) );
36 if( hfs_get_ushort(mdb
->drSigWord
) == HFS_SIGNATURE
) {
37 unsigned int n
= mdb
->drVN
[0];
40 memcpy( buf
, &mdb
->drVN
[1], n
);
42 } else if( hfs_get_ushort(mdb
->drSigWord
) == HFS_PLUS_SIGNATURE
) {
43 strncpy( buf
, "Unembedded HFS+", size
);
45 strncpy( buf
, "Error", size
);
51 os_read( int fd
, void *buf
, unsigned long len
, int blksize_bits
)
53 /* printk("os_read %d\n", (int)len); */
55 int cnt
= read_io( fd
, buf
, len
<< blksize_bits
);
56 return (cnt
> 0)? (cnt
>> blksize_bits
) : cnt
;
60 os_seek( int fd
, unsigned long blknum
, int blksize_bits
)
62 /* printk("os_seek %d\n", blknum ); */
63 long long offs
= (long long)blknum
<< blksize_bits
;
65 /* offset == -1 means seek to EOF */
66 if( (int)blknum
== -1 )
69 if( seek_io(fd
, offs
) ) {
70 /* printk("os_seek failure\n"); */
71 return (unsigned long)-1;
74 if( (int)blknum
== -1 ) {
75 if( (offs
=tell(fd
)) < 0 )
77 blknum
= offs
>> blksize_bits
;
83 os_seek_offset( int fd
, long long offset
)
89 os_same( int fd1
, int fd2
)