Lines Matching refs:ctx
74 static int rawread(struct winblk *ctx, int start, int nsecs, char *buf);
79 struct winblk *ctx = (struct winblk*)devdata;
86 dblk += ctx->start;
89 if (error = rawread(ctx, dblk, nblks, buf)) {
93 if (error = rawread(ctx, dblk + nblks, 1, ctx->buf)) {
96 memcpy((BYTE*)buf + nblks * BLKSZ, ctx->buf,
111 struct winblk *ctx = NULL;
122 ctx = (struct winblk *)alloc(sizeof(*ctx));
123 if (!ctx) {
127 f->f_devdata = ctx;
151 ctx->hDevice = CreateFile(wdevname, GENERIC_READ, 0, NULL,
153 if (ctx->hDevice == INVALID_HANDLE_VALUE) {
163 if (!DeviceIoControl(ctx->hDevice, DISK_IOCTL_GETINFO,
164 &ctx->di, sizeof(ctx->di),
175 ctx->di.di_cylinders,
176 ctx->di.di_heads,
177 ctx->di.di_sectors,
178 ctx->di.di_bytes_per_sect);
179 if (ctx->di.di_flags & DISK_INFO_FLAG_MBR) {
182 if (ctx->di.di_flags & DISK_INFO_FLAG_CHS_UNCERTAIN) {
185 if (ctx->di.di_flags & DISK_INFO_FLAG_UNFORMATTED) {
188 if (ctx->di.di_flags & DISK_INFO_FLAG_PAGEABLE) {
194 if (!(ctx->di.di_flags & DISK_INFO_FLAG_MBR) ||
195 (ctx->di.di_flags & DISK_INFO_FLAG_CHS_UNCERTAIN) ||
196 (ctx->di.di_flags & DISK_INFO_FLAG_UNFORMATTED) ||
197 (ctx->di.di_bytes_per_sect != BLKSZ)) {
206 if (error = rawread(ctx, MBR_BBSECTOR, 1, ctx->buf)) {
209 memcpy(&ctx->mbr, &ctx->buf[MBR_PART_OFFSET], sizeof(ctx->mbr));
215 ctx->mbr[i].mbrp_type,
216 ctx->mbr[i].mbrp_start,
217 ctx->mbr[i].mbrp_size,
218 ctx->mbr[i].mbrp_scyl,
219 ctx->mbr[i].mbrp_shd,
220 ctx->mbr[i].mbrp_ssect,
221 ctx->mbr[i].mbrp_ecyl,
222 ctx->mbr[i].mbrp_ehd,
223 ctx->mbr[i].mbrp_esect,
224 ctx->mbr[i].mbrp_flag));
230 ctx->start = -1;
233 if (ctx->mbr[i].mbrp_type == MBR_PTYPE_NETBSD) {
234 ctx->start = ctx->mbr[i].mbrp_start;
237 if (ctx->mbr[i].mbrp_type == MBR_PTYPE_386BSD) {
238 start_386bsd = ctx->mbr[i].mbrp_start;
241 if (ctx->start == -1) {
242 ctx->start = start_386bsd;
245 if (ctx->start == -1) {
250 ctx->start = 0;
252 ctx->start);
259 if (error = rawread(ctx, ctx->start + LABELSECTOR, 1, ctx->buf)) {
262 memcpy(&ctx->dl, &ctx->buf[LABELOFFSET], sizeof(ctx->dl));
264 if (ctx->dl.d_magic != DISKMAGIC ||
265 ctx->dl.d_magic2 != DISKMAGIC ||
266 dkcksum(&ctx->dl) != 0) {
268 ctx->start);
276 if (partition < 0 || ctx->dl.d_npartitions <= partition) {
281 ctx->start = ctx->dl.d_partitions[partition].p_offset;
282 win_printf(TEXT("start sector=0x%x\n"), ctx->start);
285 if (error && ctx) {
286 dealloc(ctx, sizeof(*ctx));
295 struct winblk *ctx = f->f_devdata;
297 dealloc(ctx, sizeof(*ctx));
310 rawread(struct winblk *ctx, int start, int nsecs, char *buf)
323 if (!DeviceIoControl(ctx->hDevice, DISK_IOCTL_READ,