Changeset 5510

Show
Ignore:
Timestamp:
06/12/12 10:48:19 (7 years ago)
Author:
cmatthew
Message:
  • lind_server.mix: When program file does not exist, fail with real error message instead of letting NaCl? fail.
  • lind_parsers.repy: Moved struct parsing code to its own module to make it easier to find.
Location:
seattle/branches/nacl_repy/seattlelib
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • seattle/branches/nacl_repy/seattlelib/lind_server.mix

    r5503 r5510  
    3232 
    3333 
    34 def log(arg): 
    35   """Turn off logging""" 
    36   pass 
     34# if not TRACE: 
     35#   def log(arg): 
     36#     """Turn off logging""" 
     37#     pass 
    3738 
    3839 
     
    175176 
    176177 
    177 def pack_stat_struct(struct_tuple): 
    178   """Given a tuple with stat fields, pack it into a string""" 
    179   (my_st_dev, my_st_ino, my_st_mode, my_st_nlink, my_st_uid, my_st_gid, 
    180    my_st_rdev, my_st_size, my_st_blksize, my_st_blocks, 
    181    my_st_atime, my_st_atimeus, my_st_mtime, \ 
    182    my_st_mtimeus, my_st_ctime, my_st_ctimeus) = struct_tuple 
    183   result = struct_pack('<Q<Q<I<I<I<I<Q<q<q<q<Q<Q<Q<Q<Q<Q', 
    184                        my_st_dev, my_st_ino, my_st_mode, my_st_nlink, \ 
    185                        my_st_uid, my_st_gid, my_st_rdev, my_st_size, \ 
    186                        my_st_blksize, my_st_blocks, my_st_atime, \ 
    187                        my_st_atimeus, my_st_mtime, my_st_mtimeus, \ 
    188                        my_st_ctime, my_st_ctimeus) 
    189   return result 
    190  
    191  
    192 def pack_statfs_struct(fsd): 
    193   """struct statfs { 
    194   long    f_type;     -- type of file system (see below) 
    195   long    f_bsize;    -- optimal transfer block size 
    196   long    f_blocks;   -- total data blocks in file system 
    197   long    f_bfree;    -- free blocks in fs 
    198   long    f_bavail;   -- free blocks avail to non-superuser 
    199   long    f_files;    -- total file nodes in file system 
    200   long    f_ffree;    -- free file nodes in fs 
    201   fsid_t  f_fsid;     -- file system id 
    202   long    f_namelen;  -- maximum length of filenames 
    203   } 
    204   """ 
    205   (tipe, bsize, blocks, bfree, bavail, files, ffree,\ 
    206    fsid, namelen, frsize, spare) = (fsd['f_type'], 
    207                                     fsd['f_bsize'], 
    208                                     fsd['f_blocks'], 
    209                                     fsd['f_bfree'], 
    210                                     fsd['f_bavail'], 
    211                                     fsd['f_files'], 
    212                                     fsd['f_files'], 
    213                                     fsd['f_fsid'], 
    214                                     fsd['f_namelen'], 
    215                                     fsd['f_frsize'], 
    216                                     fsd['f_spare']) 
    217  
    218   format = '<q<q<q<q<q<q<q<Q<q<q8s' 
    219   result = struct_pack(format, tipe, bsize, blocks, bfree, bavail, \ 
    220                        files, ffree, fsid, namelen, frsize, spare) 
    221   return result 
    222  
    223  
    224 def parse_sockaddr_struct(sock): 
    225   format = '<h>H<I<Q'  # family, port, address, padding 
    226   assert struct_calcsize(format) == 16 
    227   return struct_unpack(format, sock) 
     178include lind_parsers.repy 
    228179 
    229180include lind_fs_constants.py 
     
    484435  createthread(closure) 
    485436 
     437def _check_file(name): 
     438  if name.startswith("./"): 
     439    cleanname = name[2:] 
     440  else: 
     441    cleanname = name 
     442  try: 
     443    f = openfile(cleanname, False) 
     444    f.readat(0,100) 
     445    f.close() 
     446  except FileNotFoundError: 
     447    print "File not found:", name 
     448    exitall() 
     449     
     450 
    486451 
    487452def new_compoent(): 
     
    490455  code_loc = "liblind/com2.nexe" 
    491456  mycontext[2][PROGRAM] = code_loc 
     457   
    492458  mycontext[2][CMD_LINE] = [] 
    493459  setup_dispatcher(2) 
     
    523489  setup_component_communication(1) 
    524490  mycontext[LOCK] = createlock() 
    525  
     491  _check_file(curr_comp()[PROGRAM]) 
    526492  #if we are running a compoent, launch another one as a test. 
    527493  if "com1" in curr_comp()[PROGRAM]: