⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cd9660_rrip.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/*- * Copyright (c) 1993, 1994 *	The Regents of the University of California.  All rights reserved. * * This code is derived from software contributed to Berkeley * by Pace Willisson (pace@blitz.com).  The Rock Ridge Extension * Support code is derived from software contributed to Berkeley * by Atsushi Murai (amurai@spec.co.jp). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *	@(#)cd9660_rrip.c	8.2 (Berkeley) 1/23/94 */#include <sys/param.h>#include <sys/namei.h>#include <sys/buf.h>#include <sys/file.h>#include <sys/vnode.h>#include <sys/mount.h>#include <sys/kernel.h>#include <sys/stat.h>#include <sys/types.h>#include <sys/time.h>#include <isofs/cd9660/iso.h>#include <isofs/cd9660/cd9660_node.h>#include <isofs/cd9660/cd9660_rrip.h>#include <isofs/cd9660/iso_rrip.h>/* * POSIX file attribute */static intcd9660_rrip_attr(p,ana)	ISO_RRIP_ATTR *p;	ISO_RRIP_ANALYZE *ana;{	ana->inop->inode.iso_mode = isonum_731(p->mode_l);	ana->inop->inode.iso_uid = (uid_t)isonum_731(p->uid_l);	ana->inop->inode.iso_gid = (gid_t)isonum_731(p->gid_l);	ana->inop->inode.iso_links = isonum_731(p->links_l);	ana->fields &= ~ISO_SUSP_ATTR;	return ISO_SUSP_ATTR;}static voidcd9660_rrip_defattr(isodir,ana)	struct iso_directory_record *isodir;	ISO_RRIP_ANALYZE *ana;{	/* But this is a required field! */	printf("RRIP without PX field?\n");	cd9660_defattr(isodir,ana->inop,NULL);}/* * Symbolic Links */static intcd9660_rrip_slink(p,ana)	ISO_RRIP_SLINK  *p;	ISO_RRIP_ANALYZE *ana;{	register ISO_RRIP_SLINK_COMPONENT *pcomp;	register ISO_RRIP_SLINK_COMPONENT *pcompe;	int len, wlen, cont;	char *outbuf, *inbuf;		pcomp = (ISO_RRIP_SLINK_COMPONENT *)p->component;	pcompe = (ISO_RRIP_SLINK_COMPONENT *)((char *)p + isonum_711(p->h.length));	len = *ana->outlen;	outbuf = ana->outbuf;	cont = ana->cont;		/*	 * Gathering a Symbolic name from each component with path	 */	for (;	     pcomp < pcompe;	     pcomp = (ISO_RRIP_SLINK_COMPONENT *)((char *)pcomp + ISO_RRIP_SLSIZ						  + isonum_711(pcomp->clen))) {				if (!cont) {			if (len < ana->maxlen) {				len++;				*outbuf++ = '/';			}		}		cont = 0;				inbuf = "..";		wlen = 0;				switch (*pcomp->cflag) {					case ISO_SUSP_CFLAG_CURRENT:			/* Inserting Current */			wlen = 1;			break;					case ISO_SUSP_CFLAG_PARENT:			/* Inserting Parent */			wlen = 2;			break;					case ISO_SUSP_CFLAG_ROOT:			/* Inserting slash for ROOT */			/* start over from beginning(?) */			outbuf -= len;			len = 0;			break;					case ISO_SUSP_CFLAG_VOLROOT:			/* Inserting a mount point i.e. "/cdrom" */			/* same as above */			outbuf -= len;			len = 0;			inbuf = ana->imp->im_mountp->mnt_stat.f_mntonname;			wlen = strlen(inbuf);			break;					case ISO_SUSP_CFLAG_HOST:			/* Inserting hostname i.e. "kurt.tools.de" */			inbuf = hostname;			wlen = hostnamelen;			break;					case ISO_SUSP_CFLAG_CONTINUE:			cont = 1;			/* fall thru */		case 0:			/* Inserting component */			wlen = isonum_711(pcomp->clen);			inbuf = pcomp->name;			break;		default:			printf("RRIP with incorrect flags?");			wlen = ana->maxlen + 1;			break;		}				if (len + wlen > ana->maxlen) {			/* indicate error to caller */			ana->cont = 1;			ana->fields = 0;			ana->outbuf -= *ana->outlen;			*ana->outlen = 0;			return 0;		}				bcopy(inbuf,outbuf,wlen);		outbuf += wlen;		len += wlen;			}	ana->outbuf = outbuf;	*ana->outlen = len;	ana->cont = cont;		if (!isonum_711(p->flags)) {		ana->fields &= ~ISO_SUSP_SLINK;		return ISO_SUSP_SLINK;	}	return 0;}/* * Alternate name */static intcd9660_rrip_altname(p,ana)	ISO_RRIP_ALTNAME *p;	ISO_RRIP_ANALYZE *ana;{	char *inbuf;	int wlen;	int cont;		inbuf = "..";	wlen = 0;	cont = 0;		switch (*p->flags) {	case ISO_SUSP_CFLAG_CURRENT:		/* Inserting Current */		wlen = 1;		break;			case ISO_SUSP_CFLAG_PARENT:		/* Inserting Parent */		wlen = 2;		break;			case ISO_SUSP_CFLAG_HOST:		/* Inserting hostname i.e. "kurt.tools.de" */		inbuf = hostname;		wlen = hostnamelen;		break;			case ISO_SUSP_CFLAG_CONTINUE:		cont = 1;		/* fall thru */	case 0:		/* Inserting component */		wlen = isonum_711(p->h.length) - 5;		inbuf = (char *)p + 5;		break;			default:		printf("RRIP with incorrect NM flags?\n");		wlen = ana->maxlen + 1;		break;	}		if ((*ana->outlen += wlen) > ana->maxlen) {		/* treat as no name field */		ana->fields &= ~ISO_SUSP_ALTNAME;		ana->outbuf -= *ana->outlen - wlen;		*ana->outlen = 0;		return 0;	}		bcopy(inbuf,ana->outbuf,wlen);	ana->outbuf += wlen;		if (!cont) {		ana->fields &= ~ISO_SUSP_ALTNAME;		return ISO_SUSP_ALTNAME;	}	return 0;}static voidcd9660_rrip_defname(isodir,ana)	struct iso_directory_record *isodir;	ISO_RRIP_ANALYZE *ana;{	strcpy(ana->outbuf,"..");	switch (*isodir->name) {	default:		isofntrans(isodir->name,isonum_711(isodir->name_len),			   ana->outbuf,ana->outlen,			   1,isonum_711(isodir->flags)&4);		break;	case 0:		*ana->outlen = 1;		break;	case 1:		*ana->outlen = 2;		break;	}}/* * Parent or Child Link */static intcd9660_rrip_pclink(p,ana)	ISO_RRIP_CLINK  *p;	ISO_RRIP_ANALYZE *ana;{	*ana->inump = isonum_733(p->dir_loc) << ana->imp->im_bshift;	ana->fields &= ~(ISO_SUSP_CLINK|ISO_SUSP_PLINK);	return *p->h.type == 'C' ? ISO_SUSP_CLINK : ISO_SUSP_PLINK;}/* * Relocated directory */static intcd9660_rrip_reldir(p,ana)	ISO_RRIP_RELDIR  *p;	ISO_RRIP_ANALYZE *ana;{	/* special hack to make caller aware of RE field */	*ana->outlen = 0;	ana->fields = 0;	return ISO_SUSP_RELDIR|ISO_SUSP_ALTNAME|ISO_SUSP_CLINK|ISO_SUSP_PLINK;}static intcd9660_rrip_tstamp(p,ana)	ISO_RRIP_TSTAMP *p;	ISO_RRIP_ANALYZE *ana;{	unsigned char *ptime;		ptime = p->time;		/* Check a format of time stamp (7bytes/17bytes) */	if (!(*p->flags&ISO_SUSP_TSTAMP_FORM17)) {		if (*p->flags&ISO_SUSP_TSTAMP_CREAT)			ptime += 7;				if (*p->flags&ISO_SUSP_TSTAMP_MODIFY) {			cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_mtime);			ptime += 7;		} else			bzero(&ana->inop->inode.iso_mtime,sizeof(struct timeval));				if (*p->flags&ISO_SUSP_TSTAMP_ACCESS) {			cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_atime);			ptime += 7;		} else			ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime;				if (*p->flags&ISO_SUSP_TSTAMP_ATTR)			cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_ctime);		else			ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime;			} else {		if (*p->flags&ISO_SUSP_TSTAMP_CREAT)			ptime += 17;		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -