ppc64: Don't set Kp bit on SLB
[openbios.git] / fs / ioglue.c
blob1d33d8fda421c15e3722e495a7f1c355b93b82db
1 /*
2 * Creation Date: <2001/05/06 22:27:09 samuel>
3 * Time-stamp: <2003/12/12 02:24:56 samuel>
5 * <fs.c>
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
17 #include "config.h"
18 #include "libopenbios/bindings.h"
19 #include "fs/fs.h"
20 #include "libc/diskio.h"
21 #include "os.h"
22 #include "hfs_mdb.h"
24 /************************************************************************/
25 /* functionsions used by the various filesystems */
26 /************************************************************************/
28 char *
29 get_hfs_vol_name( int fd, char *buf, int size )
31 char sect[512];
32 hfs_mdb_t *mdb = (hfs_mdb_t*)&sect;
34 seek_io( fd, 0x400 );
35 read_io( fd, sect, sizeof(sect) );
36 if( hfs_get_ushort(mdb->drSigWord) == HFS_SIGNATURE ) {
37 unsigned int n = mdb->drVN[0];
38 if( n >= size )
39 n = size - 1;
40 memcpy( buf, &mdb->drVN[1], n );
41 buf[n] = 0;
42 } else if( hfs_get_ushort(mdb->drSigWord) == HFS_PLUS_SIGNATURE ) {
43 strncpy( buf, "Unembedded HFS+", size );
44 } else {
45 strncpy( buf, "Error", size );
47 return buf;
50 unsigned long
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;
59 unsigned long
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 )
67 offs = -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 )
76 return -1;
77 blknum = offs >> blksize_bits;
79 return blknum;
82 void
83 os_seek_offset( int fd, long long offset )
85 seek_io(fd, offset);
88 int
89 os_same( int fd1, int fd2 )
91 return fd1 == fd2;