/* * Copyright (c) 1993 by Sun Microsystems, Inc. */ #pragma ident "@(#)disk_generic.c 1.4 94/09/25 SMI" /* * This file contains functions that implement the fdisk menu commands. */ #include "global.h" #include #include #include #include #include #include #include #include #include #include "main.h" #include "analyze.h" #include "menu.h" #include "menu_command.h" #include "menu_defect.h" #include "menu_partition.h" #include "menu_fdisk.h" #include "param.h" #include "misc.h" #include "label.h" #include "startup.h" #include "partition.h" #include "prompts.h" #include "checkmount.h" #include "io.h" #include "ctlr_scsi.h" #include "auto_sense.h" #include "disk_generic.h" struct ctlr_ops genericops = { generic_rdwr, generic_ck_format, 0, 0, 0, 0, 0, }; /* * Check to see if the disk has been formatted. * If we are able to read the first track, we conclude that * the disk has been formatted. */ int generic_ck_format() { int status; /* * Try to read the first four blocks. */ status = generic_rdwr(DIR_READ, cur_file, 0, 4, (caddr_t)cur_buf, F_SILENT); return (!status); } /* * Read or write the disk. * Temporary interface until IOCTL interface finished. */ int generic_rdwr(dir, fd, blkno, secnt, bufaddr, flags) int dir; int fd; daddr_t blkno; int secnt; caddr_t bufaddr; int flags; { int tmpsec, status, tmpblk; tmpsec = secnt * UBSIZE; tmpblk = blkno * UBSIZE; if (dir == DIR_READ) { status = lseek(fd, tmpblk, SEEK_SET); if (status != tmpblk) return (status); status = read(fd, bufaddr, tmpsec); if (status != tmpsec) return (tmpsec); else return (0); } else { status = lseek(fd, tmpblk, SEEK_SET); if (status != tmpblk) return (status); status = write(fd, bufaddr, tmpsec); if (status != tmpsec) return (tmpsec); else return (0); } }