//------------------------------------------------------------------------------ Wdt::Wdt( const BufferS_t &buffer ) { if ( buffer.size() <= 0 ) { quitApp( "[WDT] buffer invalid" ); return; } // create an istream of our buffer std::stringbuf str_buf( buffer ); std::istream i_str( &str_buf ); uint32_t chunk_size = 0; // read in chunk by chunk chunk_size = readChunkHead( i_str, "MVER", (char*)&_mverChunk, sizeof( MverChunk_s ) ); chunk_size = readChunkHead( i_str, "MPHD", (char*)&_mphdChunk, sizeof( MphdChunk_s ) ); chunk_size = readChunkHead( i_str, "MAIN", (char*)&_mainChunk, sizeof( MainChunk_s ) ); // I could just say 64*64, but it's there to check that everything went right size_t count = _mainChunk.size / sizeof( MainChunk_s::AsyncObject_s ); size_t num_adts = 0; _asyncObjects.resize( count ); // read flags from buffer for ( size_t i = 0; i < count; i++ ) { i_str.read( (char*)&_asyncObjects[i], sizeof( MainChunk_s::AsyncObject_s ) ); if ( _asyncObjects[i].flags & 0x1 ) { num_adts++; } } _adtCoords.resize( num_adts ); int i = 0; for ( int y = 0; y < 64; y++ ) { for ( int x = 0; x < 64; x++ ) { // get all tiles with flag & 1 if ( _asyncObjects[y*64+x].flags & 0x1 ) { _adtCoords[i].x = x; _adtCoords[i].y = y; i++; } } } }
int svr4_stream_ioctl(struct pt_regs *regs, int fd, u_int cmd, caddr_t data) { struct file *fp; struct inode *ip; int error; fp = fget(fd); if (!fp) return -EBADF; ip = fp->f_dentry->d_inode; /* * Special hack^H^Hndling for socksys fds */ if (ip->i_sock == 0 && IS_SOCKSYS(ip)) { error = socksys_fdinit(fd, 0, NULL, NULL); if (error < 0) return error; fput(fp); fp = fget(fd); if (!fp) return -EBADF; ip = fp->f_dentry->d_inode; } switch (cmd) { case 001: /* I_NREAD */ return i_nread(fd, fp, ip, data, regs); case 017: /* I_PEEK */ return i_peek(fd, fp, ip, data, regs); } fput(fp); switch (cmd) { case 010: /* I_STR */ return i_str(fd, fp, ip, data, regs); case 002: { /* I_PUSH */ char *tmp; /* Get the name anyway to validate it. */ tmp = getname(data); if (IS_ERR(tmp)) return PTR_ERR(tmp); abi_trace(ABI_TRACE_STREAMS, "%d STREAMS I_PUSH %s\n", fd, tmp); putname(tmp); return 0; } case 003: /* I_POP */ abi_trace(ABI_TRACE_STREAMS, "%d STREAMS I_POP\n", fd); return 0; case 005: /* I_FLUSH */ return 0; case 013: { /* I_FIND */ char *tmp; /* Get the name anyway to validate it. */ tmp = getname(data); if (IS_ERR(tmp)) return PTR_ERR(tmp); abi_trace(ABI_TRACE_STREAMS, "%d STREAMS I_FIND %s\n", fd, tmp); #ifdef CONFIG_ABI_XTI if (!strcmp(tmp, "timod")) { putname(tmp); return 1; } #endif putname(tmp); return 0; } /* FIXME: These are bogus. */ case 011: /* I_SETSIG */ return sys_ioctl(fd, FIOSETOWN, (void *)current->pid); case 012: /* I_GETSIG */ return sys_ioctl(fd, FIOGETOWN, data); case 020: /* I_FDINSERT */ #ifdef CONFIG_ABI_XTI return stream_fdinsert(regs, fd, (struct strfdinsert *)data); #else return -EINVAL; #endif case 004: /* I_LOOK */ case 006: /* I_SRDOPT */ case 007: /* I_GRDOPT */ case 014: /* I_LINK */ case 015: /* I_UNLINK */ case 021: /* I_SENDFD */ case 022: /* I_RECVFD */ case 023: /* I_SWROPT */ case 040: /* I_SETCLTIME */ return 0; /* Lie... */ case 042: /* I_CANPUT */ /* * Arg is the priority band in question. We only * support one priority band so data must be 0. * If the band is writable we should return 1, if * the band is flow controlled we should return 0. */ if (data) return -EINVAL; /* FIXME: How can we test if a write would block? */ return 1; case 024: /* I_GWROPT */ case 025: /* I_LIST */ case 026: /* I_PLINK */ case 027: /* I_PUNLINK */ case 030: /* I_SETEV */ case 031: /* I_GETEV */ case 032: /* I_STREV */ case 033: /* I_UNSTREV */ case 034: /* I_FLUSHBAND */ case 035: /* I_CKBAND */ case 036: /* I_GETBAND */ case 037: /* I_ATMARK */ case 041: /* I_GETCLTIME */ /* Unsupported - drop out. */ } printk(KERN_ERR "iBCS: STREAMS ioctl 0%o unsupported\n", cmd); return -EINVAL; }