📄 cdfs_mount.c
字号:
*/ if(!strncmp(iso_fs->iso_std_id,"CD001", 5)) { switch(iso_fs->iso_vol_desc_type) { case TERMINATING_VOL_DESC: brelse(tp); hsg_fs = (struct hsg_fs *)NULL; goto found; case PRIMARY_VOL_DESC: primary_loc = loc; break; case SUPPLEMENTARY_VOL_DESC: if (!strncmp(iso_fs->iso_system_id, "DEC_ULTRIX", 10)) { supplementary_loc = loc; } } loc += (ISO_SECSIZE / DEV_BSIZE); brelse(tp); continue; } hsg_fs = (struct hsg_fs *)tp->b_un.b_fs; /* * Check the magic number and see * if formatted in HSG. */ if(!strncmp(hsg_fs->iso_std_id,"CDROM", 5)) { switch(hsg_fs->iso_vol_desc_type) { case TERMINATING_VOL_DESC: brelse(tp); iso_fs = (struct iso_fs *)NULL; goto found; case PRIMARY_VOL_DESC: primary_loc = loc; break; case SUPPLEMENTARY_VOL_DESC: if (!strncmp(hsg_fs->iso_system_id, "DEC_ULTRIX", 10)) { supplementary_loc = loc; } } loc += (ISO_SECSIZE / DEV_BSIZE); brelse(tp); continue; } uprintf("cdfs_mount: Unknown descriptor type\n"); brelse(tp); goto ERROR; } found: if (primary_loc == 0) { uprintf("cdfs_mount: Volume Descriptor Terminator found before Primary volume descriptor\n"); goto ERROR; } if (supplementary_loc == 0 || mp->m_flags & M_PRIMARY) loc = primary_loc; else { loc = supplementary_loc; if (!suser()) { mp->m_flags &= ~M_DEFPERM; mp->m_flags |= M_NODEFPERM; } } tp = bread(dev, loc, ISO_SECSIZE, (struct gnode *) NULL); if (tp->b_flags & B_ERROR) { uprintf("cdfs_mount: I/O error reading descriptor block\n"); brelse(tp); goto ERROR; } if (iso_fs) iso_fs = (struct iso_fs *)tp->b_un.b_fs; else hsg_fs = (struct hsg_fs *)tp->b_un.b_fs; bp = geteblk(MAXBSIZE); mp->m_bufp = bp; /* map the volume desc into a buffer not connected with a device */ bcopy((caddr_t)tp->b_un.b_addr, (caddr_t)&bp->b_un.b_fs->fs_block, ISO_SECSIZE); tp->state |= B_INVAL; /* Since bp does not have an associated gp */ brelse(tp); tp = 0; fs = bp->b_un.b_fs; if (iso_fs) { fs->fs_format = ISO_9660; iso_fs = (struct iso_fs *) &fs->fs_block.isofs; iso_tdir = &iso_fs->iso_root_dir; } else { fs->fs_format = ISO_HSG; hsg_fs = (struct hsg_fs *) &fs->fs_block.hsgfs; hsg_tdir = &hsg_fs->iso_root_dir; } if (isodebug) { printf("cdfs_mount: Volume Info. Block follows:\n"); printf("Volume Descriptor type = %d\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_vol_desc_type : hsg_fs->iso_vol_desc_type)); printf("std_id = <%5s>\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_std_id : hsg_fs->iso_std_id)); printf("vol desc version = %d\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_vol_desc_vers : hsg_fs->iso_vol_desc_vers)); printf("sys id = <%32s>\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_system_id : hsg_fs->iso_system_id)); printf("vol id = <%32s>\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_vol_id : hsg_fs->iso_vol_id)); printf("vol space size = %d\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_vol_space_size_lsb: hsg_fs->iso_vol_space_size_lsb)); printf("vol set size = %d\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_vol_set_size_lsb : hsg_fs->iso_vol_set_size_lsb)); printf("vol seq number = %d\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_vol_seq_num_lsb : hsg_fs->iso_vol_seq_num_lsb)); printf("logical block size = %d\n", ISOFS_LBS(fs)); printf("Root Directory:\n"); printf("\t entry len = %d\n", (fs->fs_format == ISO_9660 ? iso_tdir->dir_len : hsg_tdir->dir_len)); printf("\t xar len = %d\n", (fs->fs_format == ISO_9660 ? iso_tdir->dir_xar : hsg_tdir->dir_xar)); bcopy((fs->fs_format == ISO_9660 ? iso_tdir->dir_extent_lsb : hsg_tdir->dir_extent_lsb), convert_extent.incoming, sizeof(int)); printf("\t location = %d\n", convert_extent.outgoing); bcopy((fs->fs_format == ISO_9660 ? iso_tdir->dir_dat_len_lsb : hsg_tdir->dir_dat_len_lsb), convert_extent.incoming, sizeof(int)); printf("\t data len = %d\n", convert_extent.outgoing); printf("\t file flags = 0x%x\n", (fs->fs_format == ISO_9660 ? iso_tdir->dir_file_flags : hsg_tdir->dir_file_flags)); printf("\t unit size = %d\n", (fs->fs_format == ISO_9660 ? iso_tdir->dir_file_unit_size : hsg_tdir->dir_file_unit_size)); printf("\t gap size = %d\n", (fs->fs_format == ISO_9660 ? iso_tdir->dir_inger_gap_size : hsg_tdir->dir_inger_gap_size)); printf("\t vol seq no = %d\n", (fs->fs_format == ISO_9660 ? iso_tdir->dir_vol_seq_no_lsb : hsg_tdir->dir_vol_seq_no_lsb)); printf("\t dir name len = %d\n", (fs->fs_format == ISO_9660 ? iso_tdir->dir_namelen : hsg_tdir->dir_namelen)); printf("\t dir name = %s\n", (fs->fs_format == ISO_9660 ? iso_tdir->dir_name : hsg_tdir->dir_name)); printf("vol set size id = %60s\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_vol_set_id : hsg_fs->iso_vol_set_id)); printf("pub id = %60s\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_pub_id : hsg_fs->iso_pub_id)); printf("application id = %60s\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_application_id : hsg_fs->iso_application_id)); printf("data preparer = %60s\n", (fs->fs_format == ISO_9660 ? iso_fs->iso_preparer_id : hsg_fs->iso_preparer_id)); printf("cdfs_mount: Volume Info. Block END\n"); } fs->fs_ronly = 1; /* gfs has no knowledge of the following parameters, set them here */ /* * PRS - For field test, set m_bsize to MAXBSIZE */ mp->m_bsize = MAXBSIZE; fs->fs_ibsize = MAXBSIZE; mp->m_fstype = GT_CDFS; (void) cdfs_getfsdata(mp); /* * Since ISO9660 files do not have unique numbers on disk, * we must make our own. We will use the disk address of * the corresponding directory entry. */ if (fs->fs_format == ISO_9660) { bcopy(iso_tdir->dir_extent_lsb, convert_extent.incoming, sizeof(int)); fs->iso_rootino = (convert_extent.outgoing + iso_tdir->dir_xar) * (int)ISOFS_LBS(fs); } else { bcopy(hsg_tdir->dir_extent_lsb, convert_extent.incoming, sizeof(int)); fs->iso_rootino = (convert_extent.outgoing + hsg_tdir->dir_xar) * (int)ISOFS_LBS(fs); } if (fs->iso_rootino % ISO_SECSIZE) { printf("cdfs_mount: directory record does not begin on a logical sector boundary\n"); goto ERROR; } /* * this gget is very order dependent, do it last */ if ((gp = gget(mp, fs->iso_rootino, 0, NULL)) == NULL) { uprintf("cdfs_mount: cannot find root inode\n"); goto ERROR; } cdfs_gunlock(gp); /* point the mount table toward the root of the filesystem */ mp->m_rootgp = gp; if (isodebug) { cprintf("cdfs_mount: rootgp 0x%x (%d)\n", gp, gp->g_number); cprintf("cdfs_mount: g_mp 0x%x ops 0x%x\n", gp->g_mp, gp->g_mp->m_ops); } return (mp);ERROR: CALL_TO_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity); (*bdevsw[major(dev)].d_close)(dev, FREAD); RETURN_FROM_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity); /* something happened and we need to invalidate the buffer cache * so that later we may re-use the device */ binval(dev, (struct gnode *) 0);done: return(NULL);}cdfs_umount(mp, force) register struct mount *mp; register int force;{ register struct gnode *gp = mp->m_gnodp; register int stillopen; dev_t dev = mp->m_dev; int saveaffinity; int i; dnlc_purge(); xumount(dev); /* get rid of the sticky bitted files */ /* try to flush gnodes */#ifdef QUOTA stillopen = gflush(dev, mp->m_qinod, mp->m_rootgp);#else stillopen = gflush(dev, mp->m_rootgp);#endif if (stillopen < 0) { /* someone has a file open */ return(EBUSY); } (void) grele(mp->m_rootgp);#ifdef QUOTA closedq(mp, 0); /* there is a nasty piece of baggage with quotas, we must reflush * all the gnodes for the device to get rid of the quota gnode */ (void) gflush(dev, (struct gnode *) NULL, (struct gnode *) NULL);#endif /* make the mounted directory accessible again */ gp->g_flag &= ~GMOUNT; (void) grele(gp); if (!stillopen) { CALL_TO_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity); (*bdevsw[major(dev)].d_close)(dev, FREAD); RETURN_FROM_NONSMP_DRIVER(bdevsw[major(dev)], saveaffinity); } return(NULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -