source:
patches/silo-1.4.14-fixes-3.patch@
43ef6eb
Last change on this file since 43ef6eb was a3e5d4f, checked in by , 12 years ago | |
---|---|
|
|
File size: 31.0 KB |
-
Rules.make
Submitted By: William Harrington <kb0iic at gmail dot com> Date: 2012-09-01 Initial Package Version: 1.4.14 Upstream Status: Unknown Origin: git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/davem/silo Description: Fixes for current silo.1.4.14 not yet released. diff -Naur silo-1.4.14.orig/Rules.make silo-1.4.14/Rules.make
old new 1 VERSION=1.4.14 1 VERSION=1.4.14_git20120901 2 2 IMGVERSION=0.99 3 3 SHELL=/bin/bash 4 4 RM=rm -f … … 18 18 > /dev/null 2>&1; then echo "y"; else echo "n"; fi;) 19 19 20 20 CFLAGS = -Os -Wall -I. -I../include -fomit-frame-pointer \ 21 -fno-strict-aliasing - DSMALL_RELOC=$(SMALL_RELOC)\22 21 -fno-strict-aliasing -U_FORTIFY_SOURCE \ 22 -DSMALL_RELOC=$(SMALL_RELOC) -DLARGE_RELOC=$(LARGE_RELOC) 23 23 24 24 ifeq ($(call cc-option-yn, -fno-stack-protector),y) 25 25 CFLAGS += -fno-stack-protector -
common/.gitignore
diff -Naur silo-1.4.14.orig/common/.gitignore silo-1.4.14/common/.gitignore
old new 1 # 2 # Generated files 3 # 4 bin2h -
common/divdi3.S
diff -Naur silo-1.4.14.orig/common/divdi3.S silo-1.4.14/common/divdi3.S
old new 20 20 .data 21 21 .align 8 22 22 .globl __clz_tab 23 .register %g2,#scratch 24 .register %g3,#scratch 23 25 __clz_tab: 24 26 .byte 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 25 27 .byte 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 -
common/malloc.c
diff -Naur silo-1.4.14.orig/common/malloc.c silo-1.4.14/common/malloc.c
old new 18 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 19 USA. */ 20 20 21 #include <stringops.h> 22 21 23 #ifndef MALLOC_BASE 22 24 extern unsigned long _start; 23 25 static char *malloc_ptr = ((char *)&_start) + 0x30000; … … 27 29 28 30 static char *last_alloc = 0; 29 31 32 static char *align_ptr_to(char *ptr, unsigned long align) 33 { 34 return (char *) ((((unsigned long) ptr) + (align - 1UL)) & 35 ~(align - 1UL)); 36 } 37 30 38 void *malloc (int size) 31 39 { 32 40 char *caddr; … … 34 42 caddr = malloc_ptr; 35 43 malloc_ptr += size; 36 44 last_alloc = caddr; 37 malloc_ptr = (char *) ((((unsigned long) malloc_ptr) + 7) & (~7));45 malloc_ptr = align_ptr_to(malloc_ptr, 8UL); 38 46 return caddr; 39 47 } 40 48 49 void *calloc (int nmemb, int memb_size) 50 { 51 char *ret; 52 int size; 53 54 if (!nmemb || !memb_size) 55 return (void *) 0; 56 57 size = nmemb * memb_size; 58 ret = malloc(size); 59 60 if (ret) 61 memset(ret, 0, size); 62 63 return ret; 64 } 65 66 int posix_memalign(void **memptr, unsigned long alignment, unsigned long size) 67 { 68 char *caddr; 69 70 if (alignment & (alignment - 1UL)) 71 return -1; 72 if (alignment & (sizeof(void *) - 1UL)) 73 return -1; 74 75 if (size == 0) { 76 *memptr = (void *) 0; 77 return 0; 78 } 79 80 caddr = align_ptr_to(malloc_ptr, alignment); 81 malloc_ptr = (caddr + size); 82 last_alloc = caddr; 83 malloc_ptr = align_ptr_to(malloc_ptr, 8UL); 84 85 *memptr = caddr; 86 87 return 0; 88 } 89 41 90 void free (void *m) 42 91 { 43 92 if (m == last_alloc) -
common/printf.c
diff -Naur silo-1.4.14.orig/common/printf.c silo-1.4.14/common/printf.c
old new 21 21 USA. */ 22 22 23 23 #include "promlib.h" 24 #include <stringops.h> 24 25 25 26 /* 26 27 * This part is rewritten by Igor Timkin <ivt@msu.su>. Than I … … 147 148 vprintf (fmt, x1); 148 149 va_end (x1); 149 150 } 151 152 static int sprintn (char *str, long long n, int b) 153 { 154 static char prbuf[33]; 155 register char *cp; 156 int count = 0; 157 158 if (b == 10 && n < 0) { 159 memset (str + count, '-', 1); 160 count++; 161 n = -n; 162 } 163 cp = prbuf; 164 do 165 *cp++ = "0123456789ABCDEF"[(unsigned int) (((unsigned long)n) % b)]; 166 while ((n = ((unsigned long long)n) / b & 0x0FFFFFFFFFFFFFFFULL)); 167 do { 168 memset (str + count, *--cp, 1); 169 count++; 170 } while (cp > prbuf); 171 172 return count; 173 } 174 175 int vsprintf (char *str, char *fmt, va_list adx) 176 { 177 register int c; 178 char *s; 179 int count = 0; 180 181 for (;;) { 182 while ((c = *fmt++) != '%') { 183 memset (str + count, c, 1); 184 if (c == '\0') { 185 return count; 186 } 187 } 188 c = *fmt++; 189 if (c == 'd' || c == 'o' || c == 'x' || c == 'X') { 190 count += sprintn (str + count, (long long) va_arg (adx, unsigned), 191 c == 'o' ? 8 : (c == 'd' ? 10 : 16)); 192 } else if (c == 'c') { 193 memset (str + count, va_arg (adx, unsigned), 1); 194 count++; 195 } else if (c == 's') { 196 if ((s = va_arg (adx, char *)) == NULL) 197 s = (char *)"(null)"; 198 while ((c = *s++)) { 199 memset (str + count, c, 1); 200 count++; 201 } 202 } else if (c == 'l' || c == 'O') { 203 count += sprintn (str + count, (long long) va_arg (adx, long), c == 'l' ? 10 : 8); 204 } else if (c == 'L') { 205 int hex = 0; 206 if (*fmt == 'x') { 207 fmt++; 208 hex = 1; 209 } 210 count += sprintn (str + count, (long long) va_arg (adx, long long), hex ? 16 : 10); 211 } else { 212 /* This is basically what libc's printf does */ 213 memset (str + count, '%', 1); 214 count++; 215 memset (str + count, c, 1); 216 count++; 217 } 218 } 219 220 return count; 221 } 222 223 /* 224 * Scaled down version of C Library sprintf. 225 * Only %c %s %d (==%u) %o %x %X %l %O are recognized. 226 */ 227 228 int sprintf (char *s, char *format, ...) 229 { 230 va_list arg; 231 int done; 232 233 va_start (arg, format); 234 done = vsprintf (s, format, arg); 235 va_end (arg); 236 237 return done; 238 } -
common/udivdi3.S
diff -Naur silo-1.4.14.orig/common/udivdi3.S silo-1.4.14/common/udivdi3.S
old new 20 20 .text 21 21 .align 4 22 22 .globl __udivdi3 23 .register %g2,#scratch 24 .register %g3,#scratch 23 25 __udivdi3: 24 26 save %sp,-104,%sp 25 27 mov %i3,%o3 -
first/.gitignore
diff -Naur silo-1.4.14.orig/first/.gitignore silo-1.4.14/first/.gitignore
old new 1 # 2 # Generated files 3 # 4 fd 5 fd.b 6 fd.h 7 first 8 first.b 9 first.h 10 generic 11 generic.b 12 generic.h 13 ieee32.b 14 ultra 15 ultra.b 16 ultra.h -
first-isofs/.gitignore
diff -Naur silo-1.4.14.orig/first-isofs/.gitignore silo-1.4.14/first-isofs/.gitignore
old new 1 # 2 # Generated files 3 # 4 isofs 5 isofs.b -
include/ext2fs/ext2fs.h
diff -Naur silo-1.4.14.orig/include/ext2fs/ext2fs.h silo-1.4.14/include/ext2fs/ext2fs.h
old new 39 39 */ 40 40 #define EXT2_LIB_CURRENT_REV 0 41 41 42 #if def HAVE_SYS_TYPES_H42 #if defined(HAVE_SYS_TYPES_H) 43 43 #include <sys/types.h> 44 44 #endif 45 45 -
include/silo.h
diff -Naur silo-1.4.14.orig/include/silo.h silo-1.4.14/include/silo.h
old new 87 87 void silo_disk_close(void); 88 88 /* printf.c */ 89 89 int vprintf (char *, va_list); 90 int vsprintf (char *str, char *fmt, va_list adx); 91 int sprintf (char *s, char *format, ...); 90 92 int putchar (int); 91 93 /* malloc.c */ 92 94 void *malloc (int); … … 123 125 int decompress (char *, char *, unsigned char (*)(void), void (*)(void)); 124 126 /* main.c */ 125 127 extern enum arch architecture; 128 extern int sun4v_cpu; 126 129 /* timer.c */ 127 130 int init_timer (); 128 131 void close_timer (); -
include/stringops.h
diff -Naur silo-1.4.14.orig/include/stringops.h silo-1.4.14/include/stringops.h
old new 2 2 #define __STRINGOPS_H 3 3 4 4 #include <silo.h> 5 #include <stddef.h> 5 6 6 7 /* common */ 7 8 #ifndef __SIZE_TYPE__ 8 9 #define __SIZE_TYPE__ long unsigned int 9 10 #endif 10 #ifndef _LINUX_TYPES_H11 11 typedef __SIZE_TYPE__ size_t; 12 #endif13 12 14 13 /* stringops1.c */ 15 14 char *strcpy(char *, const char *); -
second/.gitignore
diff -Naur silo-1.4.14.orig/second/.gitignore silo-1.4.14/second/.gitignore
old new 1 # 2 # Generated files 3 # 4 second 5 second.b 6 second.b2 7 second2 8 silotftp 9 silotftp.b 10 silotftp.b2 11 silotftp2 12 util -
second/Makefile
diff -Naur silo-1.4.14.orig/second/Makefile silo-1.4.14/second/Makefile
old new 58 58 $(AR) rc $@ $(FS_OBJS) 59 59 60 60 second: $(OBJS) mark.o 61 $(LD) $(LDFLAGS_SMALL) -Bstatic -o second $(OBJS) -lext2fs mark.o62 $(LD) $(LDFLAGS_LARGE) -Bstatic -o second2 $(OBJS) -lext2fs mark.o61 $(LD) $(LDFLAGS_SMALL) -Bstatic -o second $(OBJS) mark.o `$(CC) -print-libgcc-file-name` 62 $(LD) $(LDFLAGS_LARGE) -Bstatic -o second2 $(OBJS) mark.o `$(CC) -print-libgcc-file-name` 63 63 $(NM) second | grep -v '*ABS*' | sort > second.map 64 64 65 65 silotftp: $(OBJSNET) mark.o 66 $(LD) $(LDFLAGS_SMALL) -Bstatic -o silotftp $(OBJSNET) -lext2fs mark.o67 $(LD) $(LDFLAGS_LARGE) -Bstatic -o silotftp2 $(OBJSNET) -lext2fs mark.o66 $(LD) $(LDFLAGS_SMALL) -Bstatic -o silotftp $(OBJSNET) mark.o `$(CC) -print-libgcc-file-name` 67 $(LD) $(LDFLAGS_LARGE) -Bstatic -o silotftp2 $(OBJSNET) mark.o `$(CC) -print-libgcc-file-name` 68 68 $(NM) silotftp | grep -v '*ABS*' | sort > silotftp.map 69 69 70 70 second.l: second -
second/file.c
diff -Naur silo-1.4.14.orig/second/file.c silo-1.4.14/second/file.c
old new 19 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 20 USA. */ 21 21 22 #include <sys/types.h> 22 23 #include <silo.h> 23 24 #include <file.h> 24 25 #include <stringops.h> -
second/fs/ext2.c
diff -Naur silo-1.4.14.orig/second/fs/ext2.c silo-1.4.14/second/fs/ext2.c
old new 3 3 Copyright (C) 1996 Maurizio Plaza 4 4 1996,1997,1999 Jakub Jelinek 5 5 2001 Ben Collins 6 2012 David S. Miller 6 7 7 8 This program is free software; you can redistribute it and/or modify 8 9 it under the terms of the GNU General Public License as published by … … 27 28 static ino_t inode = 0; 28 29 struct fs_ops ext2_fs_ops; 29 30 30 void com_err (const char *a, long i, const char *fmt,...) 31 #define EXT2_SUPER_MAGIC 0xEF53 32 33 static __u32 ext2_to_cpu_32(__u32 v) 31 34 { 32 printf ((char *) fmt); 35 const __u8 *p = (const __u8 *) &v; 36 37 return ((__u32)p[3] << 24 | 38 (__u32)p[2] << 16 | 39 (__u32)p[1] << 8 | 40 (__u32)p[0]); 33 41 } 34 42 35 static void ext2fs_error (int errcode)43 static __u16 ext2_to_cpu_16(__u16 v) 36 44 { 37 #if 0 38 int i; 39 for (i = 0; i < sizeof (ext2errors) / sizeof (ext2errors[0]); i++) 40 if (ext2errors[i].errnum == errcode) { 41 printf ("%s", ext2errors [i].desc); 42 return; 43 } 44 #endif 45 printf ("Unknown ext2 error: %d", errcode); 45 const __u8 *p = (const __u8 *) &v; 46 47 return ((__u16)p[1] << 8) | ((__u16)p[0]); 46 48 } 47 49 48 static int open_ext2 (char *device) 50 struct silo_ext2_state { 51 struct ext2_super_block *super; 52 53 void *scratch_block[4]; 54 __u32 scratch_block_blk[4]; 55 56 __u32 inode_size; 57 __u32 block_size; 58 __u32 addr_per_block; 59 __u32 addr_per_block_bits; 60 __u32 desc_per_block; 61 __u32 desc_per_block_bits; 62 }; 63 static struct silo_ext2_state *sstate; 64 65 static __u32 ext2_inode_size(struct silo_ext2_state *s) 49 66 { 50 int retval;67 __u32 rev = ext2_to_cpu_32(s->super->s_rev_level); 51 68 52 retval = ext2fs_open (device, EXT2_FLAG_DIRTY, 0, 0, silo_io_manager, &fs); 53 if (retval == EXT2_ET_BAD_MAGIC) 54 return 0; 55 if (retval) { 56 printf ("\n"); 57 ext2fs_error (retval); 58 printf ("\n"); 59 return 0; 60 } 61 root = EXT2_ROOT_INO; 62 return 1; 69 if (rev == 0) 70 return 128; 71 72 return ext2_to_cpu_16(s->super->s_inode_size); 63 73 } 64 74 65 static int dump_block_ext2 (ext2_filsys fs, blk_t *blocknr, 66 int blockcnt, void *private) 75 static __u32 ext2_block_size(struct silo_ext2_state *s) 67 76 { 68 return dump_block(blocknr, blockcnt); 77 __u32 x = ext2_to_cpu_32(s->super->s_log_block_size); 78 79 x += 1; 80 81 return ((__u32) 1 << x) * 512; 69 82 } 70 83 71 static int dump_ext2 (void)84 static void read_scratch_block(struct silo_ext2_state *s, __u32 block, int N) 72 85 { 73 if (ext2fs_block_iterate (fs, inode, 0, 0, dump_block_ext2, 0)) 86 if (s->scratch_block_blk[N] == block) 87 return; 88 io_channel_read_blk(fs->io, block, 1, s->scratch_block[N]); 89 s->scratch_block_blk[N] = block; 90 } 91 92 static void read_data(struct silo_ext2_state *s, __u32 block, __u32 off, __u32 len, void *buf) 93 { 94 read_scratch_block(s, block, 0); 95 memcpy(buf, s->scratch_block[0] + off, len); 96 } 97 98 static int has_extents(struct ext2_inode *ip) 99 { 100 if (ext2_to_cpu_32(ip->i_flags) & 0x80000) 101 return 1; 74 102 return 0; 103 } 104 105 #define EXT4_EXT_MAGIC 0xf30a 106 107 struct ext4_extent_header { 108 __u16 eh_magic; 109 __u16 eh_entries; 110 __u16 eh_max; 111 __u16 eh_depth; 112 __u32 eh_generation; 113 }; 114 115 struct ext4_extent_idx { 116 __u32 ei_block; 117 __u32 ei_leaf_lo; 118 __u16 ei_leaf_hi; 119 __u16 ei_unused; 120 }; 121 122 struct ext4_extent { 123 __u32 ee_block; 124 __u16 ee_len; 125 __u16 ee_start_hi; 126 __u32 ee_start_lo; 127 }; 128 129 static struct ext4_extent_header *search_leaf(struct silo_ext2_state *s, 130 struct ext2_inode *ip, 131 unsigned long long file_block) 132 { 133 struct ext4_extent_header *ehp; 134 135 ehp = (struct ext4_extent_header *) &ip->i_block[0]; 136 for (;;) { 137 unsigned long long ext_block, hi, lo; 138 struct ext4_extent_idx *idxp; 139 int i; 140 141 idxp = (struct ext4_extent_idx *) (ehp + 1); 142 143 if (ext2_to_cpu_16(ehp->eh_magic) != EXT4_EXT_MAGIC) 144 return (struct ext4_extent_header *) 0; 145 146 if (ehp->eh_depth == ext2_to_cpu_16(0)) 147 return ehp; 148 149 for (i = 0; i < ext2_to_cpu_16(ehp->eh_entries); i++, idxp++) 150 if (file_block < ext2_to_cpu_32(idxp->ei_block)) 151 break; 152 153 if (i == 0) 154 return (struct ext4_extent_header *) 0; 155 156 idxp -= 1; 157 158 hi = ((unsigned long long)ext2_to_cpu_16(idxp->ei_leaf_hi)) << 32; 159 lo = ext2_to_cpu_32(idxp->ei_leaf_lo); 160 ext_block = hi | lo; 161 162 read_scratch_block(s, ext_block, 0); 163 ehp = (struct ext4_extent_header *) s->scratch_block[0]; 164 } 165 } 166 167 #define BLOCK_MAP_ERROR (~0ULL) 168 169 static int block_to_path(struct silo_ext2_state *s, struct ext2_inode *ip, 170 int offsets[4], long file_block) 171 { 172 int ptrs_bits = s->addr_per_block_bits; 173 int ptrs = s->addr_per_block; 174 const long direct_blocks = EXT2_NDIR_BLOCKS, 175 indirect_blocks = ptrs, 176 double_blocks = (1 << (ptrs_bits * 2)); 177 int n = 0; 178 179 if (file_block < 0) { 180 printf("EXT2: Illegal file block %ld\n", file_block); 181 } else if (file_block < direct_blocks) { 182 offsets[n++] = file_block; 183 } else if ((file_block -= direct_blocks) < indirect_blocks) { 184 offsets[n++] = EXT2_IND_BLOCK; 185 offsets[n++] = file_block; 186 } else if ((file_block -= indirect_blocks) < double_blocks) { 187 offsets[n++] = EXT2_DIND_BLOCK; 188 offsets[n++] = file_block >> ptrs_bits; 189 offsets[n++] = file_block & (ptrs - 1); 190 } else if (((file_block -= double_blocks) >> (ptrs_bits * 2)) < ptrs) { 191 offsets[n++] = EXT2_TIND_BLOCK; 192 offsets[n++] = file_block >> (ptrs_bits * 2); 193 offsets[n++] = (file_block >> ptrs_bits) & (ptrs - 1); 194 offsets[n++] = file_block & (ptrs - 1); 195 } else { 196 printf("EXT2: File block %ld is too big\n", file_block); 197 } 198 199 return n; 200 } 201 202 static unsigned long long resolve_path(struct silo_ext2_state *s, 203 struct ext2_inode *ip, 204 int *offsets, int depth) 205 { 206 __u32 *p = ip->i_block + *offsets; 207 208 while (--depth) { 209 __u32 block = ext2_to_cpu_32(*p); 210 211 read_scratch_block(s, block, depth); 212 p = (__u32 *) s->scratch_block[depth] + *++offsets; 213 } 214 215 return ext2_to_cpu_32(*p); 216 } 217 218 static unsigned long long resolve_extent(struct silo_ext2_state *s, 219 struct ext4_extent_header *ehp, 220 unsigned long long file_block) 221 { 222 unsigned long long hi, lo; 223 struct ext4_extent *ep; 224 int i; 225 226 ep = (struct ext4_extent *) (ehp + 1); 227 228 for (i = 0; i < ext2_to_cpu_16(ehp->eh_entries); i++, ep++) 229 if (file_block < ext2_to_cpu_32(ep->ee_block)) 230 break; 231 232 if (i == 0) 233 return BLOCK_MAP_ERROR; 234 235 ep -= 1; 236 file_block -= ext2_to_cpu_32(ep->ee_block); 237 if (file_block >= ext2_to_cpu_16(ep->ee_len)) 238 return BLOCK_MAP_ERROR; 75 239 76 return dump_finish (); 240 hi = ((unsigned long long)ext2_to_cpu_16(ep->ee_start_hi)) << 32; 241 lo = ext2_to_cpu_32(ep->ee_start_lo); 242 243 return (hi | lo) + file_block; 77 244 } 78 245 79 static int ls_ext2_proc(struct ext2_dir_entry *dirent, int offset, 80 int blocksize, char *buf, void *private) 246 static unsigned long long file_to_disk_block(struct silo_ext2_state *s, 247 struct ext2_inode *ip, 248 unsigned long long file_block) 81 249 { 82 struct ext2_inode ino; 83 int sl = 0, name_len = dirent->name_len & 0xFF; 84 char name[256], symlink[256]; 250 if (has_extents(ip)) { 251 struct ext4_extent_header *ehp = search_leaf(s, ip, file_block); 85 252 86 strncpy(name, dirent->name, name_len); 87 name[name_len] = 0;253 if (ehp) 254 return resolve_extent(s, ehp, file_block); 88 255 89 if (ext2fs_read_inode(fs, dirent->inode, &ino)) 90 strcpy (name, "--- error ---");256 printf("EXT2: Extent leaf search for block %d failed\n", 257 (int) file_block); 91 258 92 if (LINUX_S_ISLNK (ino.i_mode)) { 93 sl = 1; 94 if (ext2fs_inode_data_blocks(fs, &ino)) { 95 if (io_channel_read_blk(fs->io, ino.i_block[0], 1, symlink)) 96 ino.i_size = 0; 259 return BLOCK_MAP_ERROR; 97 260 } else { 98 strncpy (symlink, (char *)&(ino.i_block[0]),ino.i_size); 261 int depth, offsets[4]; 262 263 depth = block_to_path(s, ip, offsets, file_block); 264 if (depth) 265 return resolve_path(s, ip, offsets, depth); 266 267 printf("EXT2: block --> path on block %d failed\n", 268 (int) file_block); 269 270 return BLOCK_MAP_ERROR; 271 } 272 } 273 274 static void read_file(struct silo_ext2_state *s, struct ext2_inode *ip, 275 __u32 off, __u32 len, void *buf) 276 { 277 unsigned long long disk_block; 278 279 disk_block = file_to_disk_block(s, ip, off / s->block_size); 280 281 read_scratch_block(s, disk_block, 0); 282 memcpy(buf, s->scratch_block[0] + (off % s->block_size), len); 283 } 284 285 static void read_group(struct silo_ext2_state *s, __u32 grp_no, 286 struct ext2_group_desc *grp) 287 { 288 __u32 first = ext2_to_cpu_32(s->super->s_first_data_block); 289 __u32 blk, offset; 290 291 blk = first + 1 + (grp_no >> s->desc_per_block_bits); 292 offset = (grp_no & (s->desc_per_block - 1)) * sizeof(*grp); 293 294 read_data(s, blk, offset, sizeof(*grp), grp); 295 } 296 297 static void read_inode(struct silo_ext2_state *s, __u32 ino, struct ext2_inode *ip) 298 { 299 __u32 grp_no, blk_no, inode_in_block, ipg, ipb; 300 struct ext2_super_block *sb = s->super; 301 struct ext2_group_desc gd; 302 303 ipg = ext2_to_cpu_32(sb->s_inodes_per_group); 304 305 grp_no = (ino - 1) / ipg; 306 read_group(s, grp_no, &gd); 307 308 blk_no = (ino - 1) % ipg; 309 inode_in_block = blk_no; 310 311 ipb = s->block_size / s->inode_size; 312 blk_no /= ipb; 313 inode_in_block %= ipb; 314 315 read_data(s, 316 ext2_to_cpu_32(gd.bg_inode_table) + blk_no, 317 inode_in_block * s->inode_size, 318 sizeof(struct ext2_inode), ip); 319 } 320 321 static int calc_ilog2(__u32 n) 322 { 323 int i = 0; 324 325 while ((n >>= 1) != 0) 326 i++; 327 328 return i; 329 } 330 331 static int open_ext2(char *device) 332 { 333 struct silo_ext2_state *s = malloc(sizeof(*s)); 334 struct ext2_super_block *sb; 335 int err, i; 336 337 if (!s) { 338 printf("Cannot allocate silo_ext2_state\n"); 339 return 0; 340 } 341 memset(s, 0, sizeof(*s)); 342 343 fs = malloc(sizeof(*fs)); 344 if (!fs) { 345 printf("Cannot allocate ext2_filsys\n"); 346 goto out_free_s; 347 } 348 memset(fs, 0, sizeof(*fs)); 349 err = silo_io_manager->open(device, 0, &fs->io); 350 if (err) { 351 printf("I/O manager open failed (err=%d)\n", err); 352 goto out_free_fs; 353 } 354 fs->io->app_data = fs; 355 356 sb = s->super = malloc(1024); 357 if (!sb) { 358 printf("Cannot allocate ext2 super block\n"); 359 goto out_free_fs; 360 } 361 362 io_channel_set_blksize(fs->io, 1024); 363 err = io_channel_read_blk(fs->io, 1, -1024, sb); 364 365 if (ext2_to_cpu_16(sb->s_magic) != EXT2_SUPER_MAGIC) { 366 printf("EXT2 superblock magic is wrong\n"); 367 goto out_free_super; 368 } 369 370 s->inode_size = ext2_inode_size(s); 371 s->block_size = ext2_block_size(s); 372 373 io_channel_set_blksize(fs->io, s->block_size); 374 375 s->addr_per_block = s->block_size / sizeof(__u32); 376 s->addr_per_block_bits = calc_ilog2(s->addr_per_block); 377 s->desc_per_block = s->block_size / sizeof(struct ext2_group_desc); 378 s->desc_per_block_bits = calc_ilog2(s->desc_per_block); 379 380 s->scratch_block[0] = malloc(s->block_size * 4); 381 if (!s->scratch_block[0]) { 382 printf("Cannot allocate ext2 scratch blocks\n"); 383 goto out_free_super; 384 } 385 for (i = 1; i < 4; i++) 386 s->scratch_block[i] = 387 s->scratch_block[i - 1] + s->block_size; 388 for (i = 0; i < 4; i++) 389 s->scratch_block_blk[i] = ~(__u32)0; 390 391 root = EXT2_ROOT_INO; 392 393 sstate = s; 394 395 return 1; 396 397 out_free_super: 398 free(s->super); 399 400 out_free_fs: 401 free(fs); 402 fs = NULL; 403 404 out_free_s: 405 free(s); 406 return 0; 407 } 408 409 void close_ext2 (void) 410 { 411 struct silo_ext2_state *s = sstate; 412 413 if (s) { 414 free(s->scratch_block[0]); 415 free(s->super); 416 free(s); 417 418 sstate = (struct silo_ext2_state *) 0; 99 419 } 100 symlink[ino.i_size] = 0; 101 } 420 } 421 422 static int dump_ext2 (void) 423 { 424 struct silo_ext2_state *s = sstate; 425 struct ext2_inode ei; 426 long file_offset; 427 int sz, blk_sz; 428 int blk_cnt; 429 430 read_inode(s, inode, &ei); 431 432 sz = ext2_to_cpu_32(ei.i_size); 433 blk_sz = s->block_size; 434 435 blk_cnt = 0; 436 for (file_offset = 0; file_offset < sz; file_offset += blk_sz) { 437 blk_t disk_block; 438 439 disk_block = file_to_disk_block(s, &ei, 440 file_offset / blk_sz); 441 if (disk_block == BLOCK_MAP_ERROR) 442 return 0; 443 444 if (disk_block) 445 dump_block(&disk_block, blk_cnt); 446 447 blk_cnt++; 448 } 449 450 return dump_finish (); 451 } 452 453 static char *read_symlink(struct silo_ext2_state *s, struct ext2_inode *ip, char *namebuf) 454 { 455 __u32 isize = ext2_to_cpu_32(ip->i_size); 456 457 if (isize <= 60) 458 return (char *) &ip->i_block[0]; 459 460 read_data(s, ext2_to_cpu_32(ip->i_block[0]), 0, isize, namebuf); 461 462 return namebuf; 463 } 464 465 static int is_symlink(__u16 mode) 466 { 467 if ((mode & 0xf000) == 0xa000) 468 return 1; 469 return 0; 470 } 471 472 typedef int (*dir_callback_t)(struct silo_ext2_state *, struct ext2_dir_entry_2 *, void *); 473 474 static int ls_callback(struct silo_ext2_state *s, struct ext2_dir_entry_2 *dirent, void *priv_data) 475 { 476 struct ext2_inode e_ino; 477 char *sym = (char *) 0; 478 char symlink_buf[256]; 479 480 read_inode(s, ext2_to_cpu_32(dirent->inode), &e_ino); 481 482 if (is_symlink(ext2_to_cpu_16(e_ino.i_mode))) 483 sym = read_symlink(s, &e_ino, symlink_buf); 484 485 register_silo_inode(ext2_to_cpu_32(e_ino.i_mtime), 486 ext2_to_cpu_32(e_ino.i_size), 487 ext2_to_cpu_16(e_ino.i_mode), 488 ext2_to_cpu_16(e_ino.i_uid), 489 ext2_to_cpu_16(e_ino.i_gid), 490 dirent->name, sym); 491 return 0; 492 } 493 494 static void iterate_dir(struct silo_ext2_state *s, __u32 ino, dir_callback_t cb, void *cb_arg) 495 { 496 struct ext2_dir_entry_2 e; 497 struct ext2_inode ei; 498 __u32 off, size; 102 499 103 register_silo_inode(ino.i_mtime, ino.i_size, ino.i_mode, ino.i_uid, 104 ino.i_gid, name, sl ? symlink : NULL);500 read_inode(s, ino, &ei); 501 size = ext2_to_cpu_32(ei.i_size); 105 502 106 return 0; 503 for (off = 0; off < size; ) { 504 read_file(s, &ei, off, 8, &e); 505 506 if (ext2_to_cpu_16(e.rec_len) == 0) 507 break; 508 509 if (ext2_to_cpu_32(e.inode) == 0 || 510 e.name_len == 0) { 511 off += ext2_to_cpu_16(e.rec_len); 512 continue; 513 } 514 515 read_file(s, &ei, off + 8, e.name_len, &e.name[0]); 516 e.name[e.name_len] = 0; 517 518 if (cb(s, &e, cb_arg)) 519 break; 520 521 off += ext2_to_cpu_16(e.rec_len); 522 } 107 523 } 108 524 109 525 static int ls_ext2 (void) 110 526 { 111 return ext2fs_dir_iterate (fs, inode, DIRENT_FLAG_INCLUDE_EMPTY, 112 0, ls_ext2_proc, NULL); 527 struct silo_ext2_state *s = sstate; 528 529 iterate_dir(s, inode, ls_callback, 0); 530 531 return 0; 532 } 533 534 static int ino_size_ext2 (void) 535 { 536 struct silo_ext2_state *s = sstate; 537 struct ext2_inode ei = { }; 538 539 read_inode(s, inode, &ei); 540 541 return ext2_to_cpu_32(ei.i_size); 542 } 543 544 struct namei_cb_arg { 545 const char *name; 546 int len; 547 ino_t *ino; 548 int found; 549 }; 550 551 static int lookup_cb(struct silo_ext2_state *s, struct ext2_dir_entry_2 *dirent, void *priv_data) 552 { 553 struct namei_cb_arg *p = priv_data; 554 555 if (p->len != dirent->name_len) 556 return 0; 557 if (strncmp(p->name, dirent->name, p->len)) 558 return 0; 559 p->found = 1; 560 *p->ino = ext2_to_cpu_32(dirent->inode); 561 return 1; 113 562 } 114 563 115 static int ino_size_ext2 (void) { 116 struct ext2_inode ei; 117 int retval; 564 static int do_lookup(struct silo_ext2_state *s, __u32 dir_ino, const char *name, 565 int namelen, ino_t *ret_ino) 566 { 567 struct namei_cb_arg arg; 568 569 arg.name = name; 570 arg.len = namelen; 571 arg.ino = ret_ino; 572 arg.found = 0; 573 574 iterate_dir(s, dir_ino, lookup_cb, &arg); 118 575 119 if ((retval = ext2fs_read_inode (fs, inode, &ei))) { 120 printf ("\n"); 121 ext2fs_error (retval); 122 printf ("\n"); 576 return arg.found ? 0 : -1; 577 } 578 579 static int open_namei(struct silo_ext2_state *s, const char *name, 580 int namelen, ino_t root, ino_t base, ino_t *ret_ino); 581 582 static int follow_link(struct silo_ext2_state *s, ino_t root, ino_t dir, 583 ino_t inode, ino_t *res_inode) 584 { 585 struct ext2_inode ei = { }; 586 char symlink_buf[256]; 587 char *sym; 588 589 read_inode(s, inode, &ei); 590 if (!is_symlink(ext2_to_cpu_16(ei.i_mode))) { 591 *res_inode = inode; 592 return 0; 593 } 594 sym = read_symlink(s, &ei, symlink_buf); 595 return open_namei(s, sym, ext2_to_cpu_32(ei.i_size), root, dir, res_inode); 596 } 597 598 static int dir_namei(struct silo_ext2_state *s, ino_t root, ino_t dir, 599 const char *pathname, int pathlen, 600 const char **name, int *namelen, 601 ino_t *res_inode) 602 { 603 const char *thisname; 604 int len, retval; 605 ino_t inode; 606 char c; 607 608 if ((c = *pathname) == '/') { 609 dir = root; 610 pathname++; 611 pathlen--; 612 } 613 while (1) { 614 thisname = pathname; 615 for (len = 0; --pathlen >= 0; len++) { 616 c = *pathname++; 617 if (c == '/') 618 break; 619 } 620 if (pathlen < 0) 621 break; 622 retval = do_lookup(s, dir, thisname, len, &inode); 623 if (retval) 624 return retval; 625 retval = follow_link(s, root, dir, inode, &dir); 626 if (retval) 627 return retval; 628 } 629 *name = thisname; 630 *namelen = len; 631 *res_inode = dir; 123 632 return 0; 124 }125 return ei.i_size;126 633 } 127 634 128 static int namei_follow_ext2 (const char *filename) { 129 int ret = ext2fs_namei_follow (fs, root, root, filename, &inode); 635 static int open_namei(struct silo_ext2_state *s, const char *name, 636 int namelen, ino_t root, ino_t base, ino_t *ret_ino) 637 { 638 const char *base_name; 639 ino_t dir_ino, inode; 640 int ret; 641 642 ret = dir_namei(s, root, base, name, namelen, 643 &base_name, &namelen, &dir_ino); 644 if (ret) 645 return ret; 646 647 if (!namelen) { 648 *ret_ino = dir_ino; 649 return 0; 650 } 130 651 131 ext2_fs_ops.have_inode = (inode) ? 1 : 0; 652 ret = do_lookup(s, dir_ino, base_name, namelen, &inode); 653 if (ret) 654 return ret; 655 656 ret = follow_link(s, root, dir_ino, inode, &inode); 657 if (ret) 658 return ret; 132 659 133 return ret; 660 *ret_ino = inode; 661 return 0; 134 662 } 135 663 136 static void print_error_ext2 (int error_val) { 137 ext2fs_error (error_val); 664 static int namei_follow_ext2 (const char *filename) 665 { 666 int ret; 667 668 ret = open_namei(sstate, filename, strlen(filename), 669 root, root, &inode); 670 671 ext2_fs_ops.have_inode = inode ? 1 : 0; 672 673 return ret; 138 674 } 139 675 140 void close_ext2 (void) { 141 ext2fs_close(fs); 676 static void print_error_ext2 (int error_val) 677 { 678 printf("error: %d", error_val); 142 679 } 143 680 144 681 struct fs_ops ext2_fs_ops = { … … 152 689 .namei_follow = namei_follow_ext2, 153 690 .have_inode = 0, 154 691 }; 155 156 /* These are silly stubs to satisfy libext2fs symbols */157 unsigned long time(void)158 {159 return 0;160 }161 162 void *realloc(void *p, int size)163 {164 return NULL;165 } -
second/ls.c
diff -Naur silo-1.4.14.orig/second/ls.c silo-1.4.14/second/ls.c
old new 18 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 19 USA. */ 20 20 21 #include <sys/types.h> 21 22 #include <silo.h> 22 23 #include <stringops.h> 23 24 -
second/main.c
diff -Naur silo-1.4.14.orig/second/main.c silo-1.4.14/second/main.c
old new 25 25 /* TODO: This file is a good candidate for rewrite from scratch. */ 26 26 27 27 #include <silo.h> 28 #include <asm/page.h> 29 #include <linux/elf.h> 28 #include <elf.h> 30 29 #include <stringops.h> 31 30 32 31 #ifndef NULL … … 65 64 CMD_LS 66 65 } load_cmd; 67 66 enum arch architecture; 67 int sun4v_cpu; 68 68 static int timer_status = 0; 69 69 static char *initrd_start; 70 70 static int initrd_size; -
second/misc.c
diff -Naur silo-1.4.14.orig/second/misc.c silo-1.4.14/second/misc.c
old new 501 501 if ((i = prom_searchsiblings(i, "MicroSPARC-IIep")) != 0) { 502 502 return sun4p; 503 503 } 504 return sun4u;504 buffer[4] = 'u'; 505 505 } 506 506 i = prom_getproperty (prom_root_node, "compatability", buffer, 8); 507 507 … … 517 517 return sun4d; 518 518 case 'e': 519 519 return sun4e; 520 case 'u':521 520 case 'v': 521 sun4v_cpu = 1; 522 /* FALLTHRU */ 523 case 'u': 522 524 return sun4u; 523 525 default: 524 526 for(i = 0; i < NUM_SUN_MACHINES; i++) -
second/muldi3.S
diff -Naur silo-1.4.14.orig/second/muldi3.S silo-1.4.14/second/muldi3.S
old new 20 20 .text 21 21 .align 4 22 22 .globl __muldi3 23 .register %g2,#scratch 24 .register %g3,#scratch 23 25 __muldi3: 24 26 save %sp, -104, %sp 25 27 wr %g0, %i1, %y -
second/timer.c
diff -Naur silo-1.4.14.orig/second/timer.c silo-1.4.14/second/timer.c
old new 156 156 } 157 157 if (!foundcpu || !clock_frequency) 158 158 clock_frequency = prom_getint(prom_root_node, "clock-frequency") / 100; 159 if (notimer ) {159 if (notimer && !sun4v_cpu) { 160 160 sun4u_notimer = 1; 161 161 __asm__ __volatile__ ("\t" 162 162 "rd %%tick_cmpr, %%g1\n\t" -
silo/.gitignore
diff -Naur silo-1.4.14.orig/silo/.gitignore silo-1.4.14/silo/.gitignore
old new 1 # 2 # Generated files 3 # 4 floppy.h 5 silo 6 silocheck -
tilo/.gitignore
diff -Naur silo-1.4.14.orig/tilo/.gitignore silo-1.4.14/tilo/.gitignore
old new 1 # 2 # Generated files 3 # 4 b.h 5 b.out 6 b2.h 7 b2.out 8 boot 9 boot2 10 maketilo
Note:
See TracBrowser
for help on using the repository browser.