Lines Matching refs:fn
1034 static Sfoff_t file_offset(Shell_t *shp, int fn, char *fname)
1036 Sfio_t *sp = shp->sftable[fn];
1043 endf.fd = fn;
1142 int trunc=0, clexec=0, fn, traceon;
1155 fn = (iof&IOUFD);
1156 if(fn==1 && shp->subshell && !shp->subshare && (flag==2 || isstring))
1158 if(shp->redir0 && fn==0 && !(iof&IOMOV))
1217 fn = nv_getnum(np);
1219 if(fn>=shp->gd->lim.open_max && !sh_iovalidfd(shp,fn))
1267 shp->subdup |= 1<<fn;
1272 if(dupfd!=1 && fn < 10)
1273 shp->subdup &= ~(1<<fn);
1338 else if((iof&IOREWRITE) && (flag==0 || flag==1 || sh_subsavefd(fn)))
1342 if(tname = io_usename(fname,&perm,fn,0))
1413 Sfio_t *sp = shp->sftable[fn];
1414 r = shp->fdstatus[fn];
1416 r = sh_iocheckfd(shp,fn);
1417 sfsprintf(io_op,sizeof(io_op),"%d\0",fn);
1433 if((off = file_offset(shp,fn,fname))<0)
1441 off=lseek(fn, off, SEEK_SET);
1460 sp = sh_iostream(shp,fn);
1464 /* close stream but not fn */
1472 return(fn);
1477 if(flag==0 || tname || (flag==1 && fn==1 && (shp->fdstatus[fn]&IONOSEEK) && shp->outpipepid && shp->outpipepid==getpid()))
1479 if(fd==fn)
1484 sh_close(fn);
1487 sh_iosave(shp,fn,indx,tname?fname:(trunc?Empty:0));
1489 else if(sh_subsavefd(fn))
1490 sh_iosave(shp,fn,indx|IOSUBSHELL,tname?fname:0);
1494 if(sh_inuse(shp,fn) || (fn && fn==shp->infd))
1496 if(fn>9 || !(shp->inuse_bits&(1<<fn)))
1497 io_preserve(shp,shp->sftable[fn],fn);
1499 sh_close(fn);
1508 fn = fd;
1511 if((fn=fcntl(fd,F_DUPFD,10)) < 0)
1513 if(fn>=shp->gd->lim.open_max && !sh_iovalidfd(shp,fn))
1516 sh_iosave(shp,fn,indx|0x10000,tname?fname:(trunc?Empty:0));
1517 shp->fdstatus[fn] = shp->fdstatus[fd];
1519 fd = fn;
1523 v = fn;
1529 fd = sh_iorenumber(shp,sh_iomovefd(fd),fn);
1530 if(fn>2 && fn<10)
1531 shp->inuse_bits |= (1<<fn);