Merge remote-tracking branch 'origin/64_and_32_bit_time_tests'
authorTimothy Manning <codedraftsman@gmail.com>
Thu, 5 Aug 2021 01:12:48 +0000 (13:12 +1200)
committerTimothy Manning <codedraftsman@gmail.com>
Thu, 5 Aug 2021 01:12:48 +0000 (13:12 +1200)
1  2 
yaffs_guts.c

diff --combined yaffs_guts.c
index c09c88f15df198fc1ae6b606e324eb81138f2ed3,4621dfa2117b33fc78abb105c389246074551b9c..41ceb5b526caca8d3a644ca1ae01eeeb55b2b52a
@@@ -163,6 -163,8 +163,8 @@@ u8 *yaffs_get_temp_buffer(struct yaffs_
  
  }
  
+ /* Frees all the temp_buffer objects in the yaffs_dev instance
+ */
  void yaffs_release_temp_buffer(struct yaffs_dev *dev, u8 *buffer)
  {
        int i;
@@@ -3017,10 -3019,8 +3019,10 @@@ static void yaffs_check_obj_details_loa
  
        result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags);
  
 -      if (result == YAFFS_FAIL)
 +      if (result == YAFFS_FAIL) {
 +              yaffs_release_temp_buffer(dev, buf);
                return;
 +      }
  
        oh = (struct yaffs_obj_hdr *)buf;
  
@@@ -3203,6 -3203,7 +3205,6 @@@ int yaffs_update_oh(struct yaffs_obj *i
                bi->has_shrink_hdr = 1;
        }
  
 -
        return new_chunk_id;
  }
  
@@@ -4887,80 -4888,6 +4889,80 @@@ int yaffs_get_n_free_chunks(struct yaff
        return n_free;
  }
  
 +/*
 + * Marshalling functions to get the appropriate time values saved
 + * and restored to/from obj headers.
 + *
 + * Note that the WinCE time fields are used to store the 32-bit values.
 + */
 +
 +static void yaffs_oh_time_load(u32 *yst_time, u32 *win_time, YTIME_T timeval)
 +{
 +      u32 upper;
 +      u32 lower;
 +
 +      lower = timeval & 0xffffffff;
 +      if (sizeof(YTIME_T) > sizeof(u32))
 +              upper = (timeval >> 32) & 0xffffffff;
 +      else
 +              upper = 0;
 +
 +      *yst_time = lower;
 +      win_time[0] = lower;
 +      win_time[1] = upper;
 +}
 +
 +static YTIME_T yaffs_oh_time_fetch(const u32 *yst_time, const u32 *win_time)
 +{
 +      u32 upper;
 +      u32 lower;
 +
 +      if (win_time[1] == 0xffffffff) {
 +              upper = 0;
 +              lower = *yst_time;
 +      } else {
 +              upper = win_time[1];
 +              lower = win_time[0];
 +      }
 +      if (sizeof(YTIME_T) > sizeof(u32)) {
 +              u64 ret;
 +              ret = (((u64)upper) << 32) | lower;
 +              return (YTIME_T) ret;
 +
 +      } else
 +              return (YTIME_T) lower;
 +}
 +
 +YTIME_T yaffs_oh_ctime_fetch(struct yaffs_obj_hdr *oh)
 +{
 +      return yaffs_oh_time_fetch(&oh->yst_ctime, oh->win_ctime);
 +}
 +
 +YTIME_T yaffs_oh_mtime_fetch(struct yaffs_obj_hdr *oh)
 +{
 +      return yaffs_oh_time_fetch(&oh->yst_mtime, oh->win_mtime);
 +}
 +
 +YTIME_T yaffs_oh_atime_fetch(struct yaffs_obj_hdr *oh)
 +{
 +      return yaffs_oh_time_fetch(&oh->yst_atime, oh->win_atime);
 +}
 +
 +void yaffs_oh_ctime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
 +{
 +      yaffs_oh_time_load(&oh->yst_ctime, oh->win_ctime, obj->yst_ctime);
 +}
 +
 +void yaffs_oh_mtime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
 +{
 +      yaffs_oh_time_load(&oh->yst_mtime, oh->win_mtime, obj->yst_mtime);
 +}
 +
 +void yaffs_oh_atime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
 +{
 +      yaffs_oh_time_load(&oh->yst_atime, oh->win_atime, obj->yst_atime);
 +}
 +
  
  /*
   * Marshalling functions to get loff_t file sizes into and out of