示例#1
0
unsigned int get_uxspecial_size(char FAR *blk)
{
 int l;

 l=UXSB_GET_SIZE(blk[0]);
 if(l==UXSB_SIZE_THRESHOLD)
  return(mget_word(blk+1)+3);
 else
  return(l+1);
}
示例#2
0
文件: ea_mgr.c 项目: OPSF/uClinux
unsigned int get_eablk_size(char FAR *blk)
{
 unsigned int rc;
 unsigned int i, total, data_len;
 char FAR *blk_ptr;

 total=mget_word(blk);
 rc=2;
 blk_ptr=blk+2;
 for(i=0; i<total; i++)
 {
  blk_ptr++;
  data_len=mget_byte(blk_ptr++);
  data_len+=mget_word(blk_ptr);
  blk_ptr+=2;
  rc+=data_len+4;
  blk_ptr+=data_len;
 }
 return(rc);
}
示例#3
0
int set_uxspecial(char FAR *storage, char *name)
{
 #if TARGET==UNIX
  char FAR *dptr;
  int l, id;
  char tmp_name[FILENAME_MAX];
  int rc;

  unlink(name);
  l=UXSB_GET_SIZE(storage[0]);
  if(l==UXSB_SIZE_THRESHOLD)
   l=mget_word(storage+1);
  id=UXSB_GET_ID(storage[0]);
  dptr=storage+((UXSB_GET_SIZE(*storage)==UXSB_SIZE_THRESHOLD)?3:1);
  switch(id)
  {
   case UXSB_FIFO:
    rc=mkfifo(name, 0644);
    return(rc?UXSPEC_RC_ERROR:0);
   case UXSB_HLNK:
   case UXSB_LNK:
    #if SFX_LEVEL>=ARJ    
     if(id==UXSB_HLNK&&suppress_hardlinks)
      return(UXSPEC_RC_SUPPRESSED);
    #endif
    if(l>=sizeof(tmp_name))
     l=sizeof(tmp_name)-1;
    far_memmove((char FAR *)tmp_name, dptr, l);
    tmp_name[l]='\0';
    rc=(id==UXSB_HLNK)?link(tmp_name, name):symlink(tmp_name, name);
    if(!rc)
     return;
    return(errno==EPERM?UXSPEC_RC_NOLINK:UXSPEC_RC_ERROR);
   case UXSB_BLK:
   case UXSB_CHR:
    /* Check for platform mismatch */
    if(sizeof(dev_t)!=l)
     return(UXSPEC_RC_FOREIGN_OS);
    rc=mknod(name, 0644|((id==UXSB_BLK)?S_IFBLK:S_IFCHR), *(dev_t FAR *)dptr);
    return(rc?UXSPEC_RC_ERROR:0);
  }
 #else
  return(UXSPEC_RC_ERROR);
 #endif
}
示例#4
0
void uxspecial_stats(char FAR *storage, int format)
{
 #if TARGET==UNIX
  FMSGP fm;
 #endif
 #if SFX_LEVEL>=ARJ
  char tmp[FILENAME_MAX-1];
  char FAR *dptr;
  int i, l, m, id;
 #endif

 if(format==UXSTATS_SHORT)
 {
  /* Only relevant under UNIX when extracting the files */
#if TARGET==UNIX  
  switch(UXSB_GET_ID(storage[0]))
  {
   case UXSB_FIFO:
    fm=M_UXSPECIAL_FIFO;
    break;
   case UXSB_HLNK:
    fm=M_UXSPECIAL_HLNK;
    break;
   case UXSB_LNK:
    fm=M_UXSPECIAL_LNK;
    break;
   case UXSB_CHR:
    fm=M_UXSPECIAL_CHR;
    break;
   case UXSB_BLK:
    fm=M_UXSPECIAL_BLK;
    break;
   default:
    return;
  }
  msg_fprintf(new_stdout, fm);
  fputc(' ', new_stdout);
#endif
 }
#if SFX_LEVEL>=ARJ
 else
 {
  l=UXSB_GET_SIZE(storage[0]);
  if(l==UXSB_SIZE_THRESHOLD)
   l=mget_word(storage+1);
  id=UXSB_GET_ID(storage[0]);
  dptr=storage+((UXSB_GET_SIZE(*storage)==UXSB_SIZE_THRESHOLD)?3:1);
  switch(id)
  {
   case UXSB_FIFO:
    arj_user_msg(M_UXLIST_FIFO);
    break;
   case UXSB_HLNK:
   case UXSB_LNK:
    if(l>=sizeof(tmp))
     l=sizeof(tmp)-1;
    far_memmove((char FAR *)tmp, dptr, l);
    tmp[l]='\0';
    msg_sprintf(misc_buf, (id==UXSB_HLNK)?M_UXLIST_HLNK:M_UXLIST_LNK, tmp);
    arj_user_msg(misc_buf);
    break;
   case UXSB_BLK:
   case UXSB_CHR:
    m=0;
    tmp[0]='\0';
    for(i=0; i<l&&m<sizeof(tmp)-4; i++)
     m+=sprintf(tmp+m, "%02x ", (unsigned char)dptr[i]);
    if(m>0)
     tmp[m-1]='\0';
    msg_sprintf(misc_buf, (id==UXSB_BLK)?M_UXLIST_BLK:M_UXLIST_CHR, tmp);
    arj_user_msg(misc_buf);
    break;
  }
 }
#endif
}
示例#5
0
文件: ea_mgr.c 项目: OPSF/uClinux
int set_ea(char FAR *i_eas, char *name)
{
 #ifdef HAVE_EAS
  int rc=0;
  char FAR *eas;
  unsigned int i, total;
  #if TARGET==OS2
   #ifdef __32BIT__
    FILESTATUS4 fs;
    EAOP2 eaop;
    char FAR *real_pfeal;
    PFEA2LIST pfeal;
    PFEA2 pf, opf;
   #else
    EAOP eaop;
    PFEALIST pfeal;
    PFEA pf;
    FILESTATUS2 fs;
    SEL selector;
   #endif
  #elif TARGET==WIN32
   PFEALIST pfeal0, pfeal;
   PFEA pf;
   struct nt_sid *sid;
   unsigned char *pstreambuf, *streambuf;
   WIN32_STREAM_ID w32sid;
   unsigned long stream_len;
  #endif

  eas=i_eas;
  if(discard_ea(name))
   return(-1);
  if((total=mget_word(eas))==0)
   return(0);
  #if TARGET==OS2
   #ifdef __32BIT__
    /* This takes the 4-byte prefixes into account (are the V1.2 EAs still
       valid if they flow beyond 64K when the oNextEntryOffset is applied?).
       Also, we ensure that it is aligned properly. In theory, there may be
       a way to crash this (72K doesn't consider the multitude of EAs) but we
       don't know/care about it -- ASR 17/10/2000 */
    real_pfeal=(char FAR *)farmalloc_msg(73728);
    pfeal=(PFEA2LIST)align_dword(real_pfeal);
    eaop.fpFEA2List=pfeal;
   #else
    if(DosAllocSeg(65535U, &selector, SEG_NONSHARED))
     return(-1);
    pfeal=(PFEALIST)MAKEP(selector, 0);
    eaop.fpFEAList=pfeal;
   #endif
  #elif TARGET==WIN32
   pstreambuf=(char *)farmalloc_msg(65536+260*total);
   pfeal=pfeal0=(PFEALIST)(streambuf=align_dword(pstreambuf));
  #endif
  eas+=2;
  pf=&pfeal->list[0];
  for(i=0; i<total; i++)
  {
   #if TARGET==OS2&&defined(__32BIT__)
    opf=pf;
   #endif
   #if TARGET==WIN32
    pf=&pfeal->list[0];
   #endif
   pf->fEA=mget_byte(eas++);
   pf->cbName=mget_byte(eas++);
   pf->cbValue=mget_word(eas);
   eas+=2;
   #if TARGET==OS2&&defined(__32BIT__)
     far_memmove((char FAR *)pf+sizeof(FEA2)-1, eas, pf->cbName);
     *((char FAR *)pf+sizeof(FEA2)-1+pf->cbName)='\0';
   #else /* Win32 or OS/2-16 */
     far_memmove((char FAR *)pf+sizeof(FEA), eas, pf->cbName);
     *((char FAR *)pf+sizeof(FEA)+pf->cbName)='\0';
   #endif
   eas+=pf->cbName;
   #if TARGET==OS2&&defined(__32BIT__)
    far_memmove((char FAR *)pf+sizeof(FEA2)+pf->cbName, eas, pf->cbValue);
   #else /* Win32 or OS/2-16 */
    far_memmove((char FAR *)pf+sizeof(FEA)+pf->cbName+1, eas, pf->cbValue);
   #endif
   eas+=pf->cbValue;
   #if SFX_LEVEL>=ARJ
    #if TARGET==OS2&&defined(__32BIT__)
     if(ea_filter((char FAR *)pf+sizeof(FEA2), 0)&&((pf->fEA&FEA_NEEDEA)||!crit_eas))
    #else /* Win32 or OS/2-16 */
     if(ea_filter((char FAR *)pf+sizeof(FEA), 0)&&((pf->fEA&FEA_NEEDEA)||!crit_eas))
    #endif
   #endif
   /* Update the offsets */
   #if TARGET==OS2
    #ifdef __32BIT__
     pf=(PFEA2)((char FAR *)pf+sizeof(FEA2)+pf->cbName+pf->cbValue);
    #else
     pf=(PFEA)((char FAR *)pf+sizeof(FEA)+pf->cbName+1+pf->cbValue);
    #endif
    /* Align at DWORD boundary and issue the list fixups */
    #ifdef __32BIT__
     pf=(PFEA2)align_dword((char FAR *)pf);
     opf->oNextEntryOffset=(i+1==total)?0:(char FAR *)pf-(char FAR *)opf;
    #endif
   #elif TARGET==WIN32
    pfeal=(PFEALIST)((char FAR *)pfeal+sizeof(FEALIST)+pf->cbName+1+pf->cbValue);
    if(i<total-1)
     pfeal=(PFEALIST)align_dword((char FAR*)pfeal);
    pfeal0->cbList=(i==total-1)?
                   0:
                   (((char FAR *)pfeal)-((char FAR *)pfeal0));
    pfeal0=pfeal;
   #endif
  }
  #if TARGET==OS2
   pfeal->cbList=(char FAR *)pf-(char FAR *)pfeal;
   #ifdef __32BIT__
    rc=DosSetPathInfo((PSZ)name, FIL_QUERYEASIZE, (PBYTE)&eaop, sizeof(eaop), 0);
    farfree(real_pfeal);
   #else
    rc=DosSetPathInfo((PSZ)name, FIL_QUERYEASIZE, (PBYTE)&eaop, sizeof(eaop), 0, 0L);
    DosFreeSeg(selector);
   #endif
   if(!rc)
   {
    #ifdef __32BIT__
     if(DosQueryPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs)))
    #else
     if(DosQPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs), 0L))
    #endif
     rc=-1;
    else
     if(fs.cbList<=4)
      rc=-1;
   }
  #elif TARGET==WIN32
   if((sid=open_streams(name, 1))==NULL)
    rc=-1;
   else
   {
    memset(&w32sid, 0, sizeof(w32sid));
    w32sid.dwStreamId=BACKUP_EA_DATA;
    w32sid.Size.LowPart=stream_len=(((char FAR *)pfeal)-streambuf);
    if(create_stream(&w32sid, sid)||write_stream(streambuf, stream_len, sid)<stream_len)
     rc=-1;
    close_streams(sid);
   }
   free(pstreambuf);
  #endif
  return(rc);
 #else
  return(-1);
 #endif
}
示例#6
0
文件: ea_mgr.c 项目: OPSF/uClinux
int query_ea(char FAR **dest, char *name, int skip_ln)
{
 #ifdef HAVE_EAS
  ULONG count, j;
  #if TARGET==OS2
   #ifdef __32BIT__
    EAOP2 eaop;
    PGEA2LIST pgeal;
    PFEA2LIST pfeal;
    APIRET rc;
    PDENA2 pdena;
    FILESTATUS4 fs;
   #else
    EAOP eaop;
    PGEALIST pgeal;
    PFEALIST pfeal;
    USHORT rc;
    PDENA1 pdena;
    FILESTATUS2 fs;
   #endif
  #elif TARGET==WIN32
   struct nt_sid *sid;
   unsigned char *streambuf;
   unsigned long stream_len;
   PFEALIST pfeal;
  #endif
  int rcode=0;
  char FAR *dptr, FAR *nptr;

  #if TARGET==OS2
   pdena=farmalloc_msg(sizeof(*pdena)+CCHMAXPATHCOMP);
   #ifdef __32BIT__
    pgeal=(PGEA2LIST)farmalloc_msg(sizeof(GEA2LIST)+CCHMAXPATHCOMP);
    if(DosQueryPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs)))
     return(-1);
   #else
    pgeal=(PGEALIST)farmalloc_msg(sizeof(GEALIST)+CCHMAXPATHCOMP);
    if(DosQPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs), 0L))
     return(-1);
   #endif
   if(fs.cbList<4)
    fs.cbList=4;                         /* Fix for Ext2FS */
   /* Allocate enough space to hold EA block */
   #ifdef __32BIT__
    *dest=(char FAR *)farmalloc_msg((int)fs.cbList*2); /* SDK does recommend it */
   #else
    *dest=(char FAR *)farmalloc_msg((int)fs.cbList-2);
   #endif
  #elif TARGET==WIN32
   if((sid=open_streams(name, 0))==NULL)
    return(-1);
   stream_len=seek_stream_id(BACKUP_EA_DATA, sid);
   if(stream_len==0||stream_len>65535)
   {
    close_streams(sid);
    *dest=(char FAR *)farmalloc_msg(2);
    dptr=*dest;
    mput_word(0, dptr);
    return(0);
   }
   /* It's a plain FEALIST, so doesn't require much caution */
   streambuf=(char FAR *)farmalloc_msg((int)stream_len);
   *dest=(char FAR *)farmalloc_msg((int)stream_len);
   if((stream_len=read_stream(streambuf, stream_len, sid))==0)
   {
    close_streams(sid);
    dptr=*dest;
    mput_word(0, dptr);
    free(streambuf);
    return(0);
   }
  #endif
  /* Initialize storage */
  dptr=*dest;
  mput_word(0, dptr);
  dptr+=2;
  j=0L;
  while(1)
  {
   #if TARGET==OS2
    count=1L;
    #ifdef __32BIT__
     if(DosEnumAttribute(ENUMEA_REFTYPE_PATH, (PVOID)name, ++j, (PVOID)pdena,
                         sizeof(*pdena)+CCHMAXPATHCOMP, &count,
                         ENUMEA_LEVEL_NO_VALUE))
      break;
    #else
     if(DosEnumAttribute(ENUMEA_REFTYPE_PATH, (PVOID)name, ++j, (PVOID)pdena,
                         sizeof(*pdena)+CCHMAXPATHCOMP, &count,
                         ENUMEA_LEVEL_NO_VALUE, 0L))
      break;
    #endif
    if(count==0L)
     break;
    /* EA (pdena->szName) consumes (pdena->cbValue) bytes */
    #ifdef __32BIT__
     eaop.fpGEA2List=pgeal;
    #else
     eaop.fpGEAList=pgeal;
    #endif
    far_strcpy(pgeal->list[0].szName, pdena->szName);
    pgeal->list[0].cbName=pdena->cbName;
    #ifdef __32BIT__
     pgeal->list[0].oNextEntryOffset=0;
     pgeal->cbList=sizeof(GEA2LIST)+pdena->cbName;
     eaop.fpGEA2List=pgeal;
     pfeal=(PFEA2LIST)farmalloc_msg(sizeof(FEA2LIST)+pdena->cbName+pdena->cbValue+1);
     pfeal->cbList=sizeof(FEA2LIST)+pdena->cbName+pdena->cbValue+1;
     eaop.fpFEA2List=pfeal;
     if((rc=DosQueryPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop)))!=0)
     {
      farfree(pfeal);
      rcode=-1;
      break;
     }
     nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA2)-1;
    #else
     pgeal->cbList=sizeof(GEALIST)+pdena->cbName;
     eaop.fpGEAList=pgeal;
     pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+pdena->cbName+pdena->cbValue+1);
     pfeal->cbList=sizeof(FEALIST)+pdena->cbName+pdena->cbValue+1;
     eaop.fpFEAList=pfeal;
     if((rc=DosQPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop), 0L))!=0)
     {
      farfree(pfeal);
      rcode=-1;
      break;
     }
     nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA);
    #endif
   #elif TARGET==WIN32
    /* Win32 provides us with a FEALIST at our disposal. */
    pfeal=(PFEALIST)streambuf;
    nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA);
   #endif
  #if SFX_LEVEL>=ARJ
   if(ea_filter(nptr, skip_ln)&&((pfeal->list[0].fEA&FEA_NEEDEA)||!crit_eas))
  #endif
   {
    mput_word(mget_word(*dest)+1, *dest);
    mput_byte(pfeal->list[0].fEA, dptr++);
    mput_byte(pfeal->list[0].cbName, dptr++);
    mput_word(pfeal->list[0].cbValue, dptr);
    dptr+=2;
    far_memmove(dptr, nptr, (int)pfeal->list[0].cbName);
    dptr+=pfeal->list[0].cbName;
    far_memmove(dptr, nptr+pfeal->list[0].cbName+1, pfeal->list[0].cbValue);
    dptr+=pfeal->list[0].cbValue;
   }
   #if TARGET==OS2
    farfree(pfeal);
   #elif TARGET==WIN32
    if(pfeal->cbList==0)                /* Indicates the last EA */
     break;
    streambuf+=pfeal->cbList;
   #endif
  }
  #if TARGET==OS2
   farfree(pdena);
   farfree(pgeal);
  #endif
  #if TARGET==WIN32
   close_streams(sid);
  #endif
  return(rcode);
 #else
  return(-1);
 #endif
}
示例#7
0
文件: ea_mgr.c 项目: OPSF/uClinux
unsigned int get_num_eas(char FAR *blk)
{
 return(mget_word(blk));
}