Example #1
0
static int read_pack_hdr(pack_hdr *out, git_file fd)
{
	pack_hdr hdr;

	if (gitfo_read(fd, &hdr, sizeof(hdr)))
		return GIT_ERROR;

	out->sig = decode32(&hdr.sig);
	out->ver = decode32(&hdr.ver);
	out->cnt = decode32(&hdr.cnt);

	return GIT_SUCCESS;
}
Example #2
0
static int pack_openidx(git_pack *p)
{
	gitlck_lock(&p->lock);

	if (p->invalid) {
		gitlck_unlock(&p->lock);
		return GIT_ERROR;
	}

	if (++p->idxcnt == 1 && !p->idx_search) {
		int status, version;
		uint32_t *data;

		if (pack_stat(p) || pack_openidx_map(p)) {
			p->invalid = 1;
			p->idxcnt--;
			gitlck_unlock(&p->lock);
			return GIT_ERROR;
		}
		data = p->idx_map.data;
		status = GIT_SUCCESS;
		version = 1;

		if (decode32(&data[0]) == PACK_TOC)
			version = decode32(&data[1]);

		switch (version) {
		case 1:
			status = pack_openidx_v1(p);
			break;
		case 2:
			status = pack_openidx_v2(p);
			break;
		default:
			status = GIT_ERROR;
		}

		if (status != GIT_SUCCESS) {
			gitfo_free_map(&p->idx_map);
			p->invalid = 1;
			p->idxcnt--;
			gitlck_unlock(&p->lock);
			return status;
		}
	}

	gitlck_unlock(&p->lock);
	return GIT_SUCCESS;
}
Example #3
0
image_frame_rgbx::image_frame_rgbx(struct packet& p)
{
	if(p.rp_major != 0) {
		std::stringstream str;
		str << "frame_from_packet: Incorrect major type (" << p.rp_major << ", should be 0)";
		throw std::runtime_error(str.str());
	}
	if(p.rp_minor != 0 && p.rp_minor != 1) {
		std::stringstream str;
		str << "frame_from_packet: Unknown minor type (" << p.rp_minor << ", should be 0 or 1)";
		throw std::runtime_error(str.str());
	}
	if(p.rp_payload.size() < 4)
		throw std::runtime_error("frame_from_packet: Malformed payload (image parameters missing)");

	uint32_t ihdr = decode32(&p.rp_payload[0]);
	width = ihdr / 65536;
	height = ihdr % 65536;
	imagedata = new unsigned char[4 * width * height];

	if(p.rp_minor == 0)
		memcpy(imagedata, &p.rp_payload[4], 4 * width * height);
	else if(p.rp_minor == 1)
		try {
			decode_zlib(imagedata, &p.rp_payload[4], p.rp_payload.size() - 4, width * height);
		} catch(...) {
			delete[] imagedata;
			imagedata = NULL;
			throw;
		}
}
Example #4
0
static int idxv1_search_offset(uint32_t *out, git_pack *p, off_t offset)
{
	if (offset > 0 && offset < (p->pack_size - GIT_OID_RAWSZ)) {
		uint32_t lo = 0, hi = p->obj_cnt+1;
		unsigned char *data = p->im_oid;
		uint32_t *idx = p->im_off_idx;
		do {
			uint32_t mid = (lo + hi) >> 1;
			uint32_t n = idx[mid];
			uint32_t pos = n * (GIT_OID_RAWSZ + 4);
			off_t here = decode32(data + pos);
			if (offset < here)
				hi = mid;
			else if (offset == here) {
				*out = n;
				return GIT_SUCCESS;
			} else
				lo = mid + 1;
		} while (lo < hi);
	}
Example #5
0
static struct tzinfo *
do_read_tzfile(int fd, const char *tzfile, int time_size)
{
  struct tzinfo *tz = NULL;
  int size, n;
  bool has_64bit_times = 0;
  int isstdcnt, isgmtcnt;

  {
    char magic[5] = { '\0' };

    if (read(fd, magic, 4) != 4) {
      do_rawlog(LT_ERR, "tz: Unable to read header from %s: %s.\n", tzfile,
                strerror(errno));
      goto error;
    }

    if (memcmp(magic, TZMAGIC, 4) != 0) {
      do_rawlog(LT_ERR, "tz: %s is not a valid tzfile. Wrong magic number.\n",
                tzfile);
      goto error;
    }
  }

  {
    char version[16];
    if (read(fd, version, 16) != 16) {
      do_rawlog(LT_ERR, "tz: Unable to read chunk from %s: %s\n", tzfile,
                strerror(errno));
      goto error;
    }

    /* There's a second copy of the data using 64 bit times, following
       the chunk with 32 bit times. */
    if (version[0] == '2')
      has_64bit_times = 1;
  }

  tz = mush_malloc(sizeof *tz, "timezone");
  memset(tz, 0, sizeof *tz);

  {
    int32_t counts[6];

    READ_CHUNK(counts, sizeof counts);

    isgmtcnt = decode32(counts[0]);
    isstdcnt = decode32(counts[1]);
    tz->leapcnt = decode32(counts[2]);
    tz->timecnt = decode32(counts[3]);
    tz->typecnt = decode32(counts[4]);
    tz->charcnt = decode32(counts[5]);
  }

  /* Use 64-bit time_t version on such systems. */
  if (has_64bit_times && sizeof(time_t) == 8 && time_size == 4) {
    off_t skip = 44;            /* Header and sizes */

    skip += tz->timecnt * 5;
    skip += tz->typecnt * 6;
    skip += tz->charcnt;
    skip += tz->leapcnt * (4 + time_size);
    skip += isgmtcnt + isstdcnt;

    if (lseek(fd, skip, SEEK_SET) < 0) {
      do_rawlog(LT_ERR, "tz: Unable to seek to second section of %s: %s\n",
                tzfile, strerror(errno));
      goto error;
    }

    mush_free(tz, "timezone");
    return do_read_tzfile(fd, tzfile, 8);
  }
#define READ_TRANSITIONS(type, decode)			\
  do {							\
    type *buf;						\
    							\
    size = tz->timecnt * time_size;			\
    buf = malloc(size);						\
    READ_CHUNKF(buf, size);					\
    								\
    tz->transitions = calloc(tz->timecnt, sizeof(time_t));	\
    for (n = 0; n < tz->timecnt; n += 1)			\
      tz->transitions[n] = (time_t) decode(buf[n]);		\
    								\
    free(buf);							\
  } while (0)

  if (time_size == 4) {
    READ_TRANSITIONS(int32_t, decode32);
  } else {
    READ_TRANSITIONS(int64_t, decode64);
  }

  tz->offset_indexes = malloc(tz->timecnt);
  READ_CHUNK(tz->offset_indexes, tz->timecnt);

  {
    uint8_t *buf;
    int m, size = tz->typecnt * 6;

    buf = malloc(size);
    READ_CHUNKF(buf, size);

    tz->offsets = calloc(tz->typecnt, sizeof(struct ttinfo));

    for (n = 0, m = 0; n < tz->typecnt; n += 1, m += 6) {
      int32_t gmtoff;

      memcpy(&gmtoff, &buf[m], 4);
      tz->offsets[n].tt_gmtoff = decode32(gmtoff);
      tz->offsets[n].tt_isdst = buf[m + 4];
      tz->offsets[n].tt_abbrind = buf[m + 5];
      tz->offsets[n].tt_std = tz->offsets[n].tt_utc = 0;
    }

    free(buf);
  }

  tz->abbrevs = malloc(tz->charcnt);
  READ_CHUNK(tz->abbrevs, tz->charcnt);

#define READ_LEAPSECS(type, decode) \
  do {				    \
    type *buf;					 \
    int m, size = tz->leapcnt * (4 + time_size); \
    						 \
    buf = malloc(size);				 \
    READ_CHUNKF(buf, size);			 \
    									\
    tz->leapsecs = calloc(tz->leapcnt, sizeof(struct ttleapsecs));	\
    									\
    for (n = 0, m = 0; n < tz->leapcnt; n += 1, m += (4 + time_size)) { \
       type when;							\
      int32_t secs;							\
      									\
      memcpy(&when, buf, time_size);					\
      memcpy(&secs, buf + time_size, 4);				\
      tz->leapsecs[n].tt_when = (time_t) decode(when);			\
      tz->leapsecs[n].tt_secs = decode32(secs);				\
    }									\
    free(buf);								\
  } while (0)

  if (tz->leapcnt) {
    if (time_size == 4)
      READ_LEAPSECS(int32_t, decode32);
    else
      READ_LEAPSECS(int64_t, decode64);
  }

  {
    uint8_t *buf;
    int n;

    buf = malloc(isstdcnt);
    READ_CHUNKF(buf, isstdcnt);

    for (n = 0; n < isstdcnt; n += 1)
      tz->offsets[n].tt_std = buf[n];

    free(buf);

    buf = malloc(isgmtcnt);
    READ_CHUNKF(buf, isgmtcnt);

    for (n = 0; n < isgmtcnt; n += 1)
      tz->offsets[n].tt_utc = buf[n];

    free(buf);
  }

  return tz;

error:
  if (tz)
    free_tzinfo(tz);
  return NULL;
}
static
int loadLocalTimeDescriptors(
                bsl::vector<baltzo::LocalTimeDescriptor> *descriptors,
                const bsl::vector<RawLocalTimeType>&      localTimeDescriptors,
                const bsl::vector<char>&                  abbreviationBuffer)
    // Load the specified 'descriptors' with the sequence of local time
    // descriptors described by the specified 'localTimeDescriptors' holding
    // raw information read from the file, and referring to null-terminated
    // abbreviations in the specified 'abbreviationBuffer'.  Return 0 on
    // success, and a non-zero value otherwise.
{
    BALL_LOG_SET_CATEGORY(LOG_CATEGORY);

    for (bsl::size_t i = 0; i < localTimeDescriptors.size(); ++i) {
        if (!validIndex(abbreviationBuffer,
                        localTimeDescriptors[i].d_abbreviationIndex)) {
            BALL_LOG_ERROR << "Invalid abbreviation buffer index "
                           << (int)localTimeDescriptors[i].d_abbreviationIndex
                           << " found in Zoneinfo file.  Expecting [0 .. "
                           << abbreviationBuffer.size() - 1
                           << "]."
                           << BALL_LOG_END;
            return -20;                                               // RETURN
        }

        const int utcOffset = decode32(localTimeDescriptors[i].d_offset);

        if (!baltzo::LocalTimeDescriptor::isValidUtcOffsetInSeconds(
                                                                  utcOffset)) {
            BALL_LOG_ERROR << "Invalid UTC offset "
                           << utcOffset
                           << " found in Zoneinfo file.  Expecting "
                           << "[-86399 .. 86399]."
                           << BALL_LOG_END;

            return -21;                                               // RETURN
        }
        const bool isDst = localTimeDescriptors[i].d_isDst;

        // Passing the address of the first character pointed by the index (C
        // string).

        const char *description =
              &abbreviationBuffer[localTimeDescriptors[i].d_abbreviationIndex];

        // Check if 'description' is null-terminated.

        const int maxLength = abbreviationBuffer.size()
                              - localTimeDescriptors[i].d_abbreviationIndex
                              - 1;
        if (maxLength < bdlb::String::strnlen(description, maxLength + 1)) {
            BALL_LOG_ERROR << "Abbreviation string is not null-terminated."
                           << BALL_LOG_END;
            return -22;                                               // RETURN
        }

        descriptors->push_back(baltzo::LocalTimeDescriptor(utcOffset,
                                                          isDst,
                                                          description));
    }

    return 0;
}
static inline
int readHeader(baltzo::ZoneinfoBinaryHeader *result, bsl::istream& stream)
    // Extract header information from the specified 'stream' and, if the data
    // meets the requirements of the Zoneinfo binary file format, populate the
    // specified 'result' with the extracted information.  Return 0 if 'result'
    // is successfully read, and a non-zero value otherwise.
{
    BSLS_ASSERT(result);

    BALL_LOG_SET_CATEGORY(LOG_CATEGORY);

    RawHeader rawHeader;
    if (!stream.read((char *)&rawHeader, sizeof(RawHeader))) {
        BALL_LOG_ERROR << "Unable to read Zoneinfo header." << BALL_LOG_END;
        return -1;                                                    // RETURN
    }

    if (0 != bsl::memcmp(EXPECTED_HEADER_ID, rawHeader.d_headerId, 4)) {
        bsl::string headerId;
        formatHeaderId(&headerId, rawHeader.d_headerId, 4);
        BALL_LOG_ERROR << "Did not find expected header id.  Expecting "
                       << "'TZif', found '" + headerId + "'"
                       << BALL_LOG_END;
        return -2;                                                    // RETURN
    }

    char version = *rawHeader.d_version;
    if ('\0' != version && '2' != version) {
        BALL_LOG_ERROR << "Found unexpected version value: "
                       << (int)version
                       << " ('"
                       << version
                       << "').  Expecting '\\0' or '2'."
                       << BALL_LOG_END;
        return -3;                                                    // RETURN
    }
    result->setVersion(version);

    int numLocalTimeTypes = decode32(rawHeader.d_numLocalTimeTypes);
    if (0 >= numLocalTimeTypes) {
        BALL_LOG_ERROR << "Empty list of local-time types in Zoneinfo file."
                       << BALL_LOG_END;
        return -4;                                                    // RETURN
    }
    result->setNumLocalTimeTypes(numLocalTimeTypes);

    int numIsGmt = decode32(rawHeader.d_numIsGmt);
    if (0 > numIsGmt) {
        BALL_LOG_ERROR << "Invalid number of 'isGmt' flags "
                       << numIsGmt
                       << " found in Zoneinfo file."
                       << BALL_LOG_END;
        return -5;                                                    // RETURN
    }
    result->setNumIsGmt(numIsGmt);

    int numIsStd = decode32(rawHeader.d_numIsStd);
    if (0 > numIsStd) {
        BALL_LOG_ERROR << "Invalid number of 'isStd' flags "
                       << numIsStd
                       << " found in Zoneinfo file."
                       << BALL_LOG_END;
        return -6;                                                    // RETURN
    }
    result->setNumIsStd(numIsStd);

    // The 'isGmt' and 'isStd' values provide information about the transition
    // times associated with a local-time type, so the number of values (i.e.,
    // 'numIsGmt' and 'numIsStd') should be the same as the number of
    // local-time types.  They may also be 0 for backward compatibility reason.

    if ((0 != numIsGmt && numIsGmt != numLocalTimeTypes)
        || (0 != numIsStd && numIsStd != numLocalTimeTypes)) {
        BALL_LOG_WARN << "Unexpected number of isGmt or isStd values in "
                      << "Zoneinfo file."
                      << BALL_LOG_END;
    }

    int numLeaps = decode32(rawHeader.d_numLeaps);
    if (0 != numLeaps) {
        BALL_LOG_ERROR << "Non-zero number of leap corrections found in "
                       << "Zoneinfo file.  Leap correction is not supported "
                       << "by 'baltzo::ZoneinfoBinaryReader'."
                       << BALL_LOG_END;
        return -7;                                                    // RETURN
    }
    result->setNumLeaps(numLeaps);

    int numTransitions = decode32(rawHeader.d_numTransitions);
    if (0 > numTransitions) {
        BALL_LOG_ERROR << "Invalid number of transitions found in Zoneinfo "
                       << "file."
                       << BALL_LOG_END;
        return -8;                                                    // RETURN
    }
    result->setNumTransitions(numTransitions);

    int abbrevDataSize = decode32(rawHeader.d_abbrevDataSize);
    if (0 >= abbrevDataSize) {
        BALL_LOG_ERROR << "No abbreviations data found in Zoneinfo file."
                       << BALL_LOG_END;
        return -9;                                                    // RETURN
    }
    result->setAbbrevDataSize(abbrevDataSize);

    return 0;
}
Example #8
0
static int replay_log_stage2(struct replay *rp, struct buffer_head *logbuf)
{
	if(DEBUG_MODE_K==1)
	{
		printk(KERN_INFO"%25s  %25s  %4d  #in\n",__FILE__,__func__,__LINE__);
	}
	struct sb *sb = rp->sb;
	struct logblock *log = bufdata(logbuf);
	block_t blocknr = rp->blocknrs[bufindex(logbuf)];
	unsigned char *data = log->data;
	int err;

	/*
	 * Log block address itself works as balloc log, and adjust
	 * bitmap and deunify even if logblocks is before latest
	 * unify, to prevent to be overwritten. (This must be after
	 * LOG_FREEBLOCKS replay if there is it.)
	 */
	trace("LOG BLOCK: logblock %Lx", blocknr);
	err = replay_update_bitmap(rp, blocknr, 1, 1);
	if (err)
		return err;
	/* Mark log block as deunify block */
	defer_bfree(&sb->deunify, blocknr, 1);

	/* If log is before latest unify, those were already applied to FS. */
	if (bufindex(logbuf) < rp->unify_index) {
//		assert(0);	/* older logs should already be freed */
		return 0;
	}
	if (bufindex(logbuf) == rp->unify_index)
		data = rp->unify_pos;

	while (data < log->data + be16_to_cpu(log->bytes)) {
		u8 code = *data++;
		switch (code) {
		case LOG_BALLOC:
		case LOG_BFREE:
		case LOG_BFREE_ON_UNIFY:
		case LOG_BFREE_RELOG:
		{
			u64 block;
			u32 count;
			data = decode32(data, &count);
			data = decode48(data, &block);
			trace("%s: count %u, block %Lx",
			      log_name[code], count, block);

			err = 0;
			if (code == LOG_BALLOC)
				err = replay_update_bitmap(rp, block, count, 1);
			else if (code == LOG_BFREE_ON_UNIFY)
				defer_bfree(&sb->deunify, block, count);
			else
				err = replay_update_bitmap(rp, block, count, 0);
			if (err)
				return err;
			break;
		}
		case LOG_LEAF_REDIRECT:
		case LOG_BNODE_REDIRECT:
		{
			u64 oldblock, newblock;
			data = decode48(data, &oldblock);
			data = decode48(data, &newblock);
			trace("%s: oldblock %Lx, newblock %Lx",
			      log_name[code], oldblock, newblock);
			err = replay_update_bitmap(rp, newblock, 1, 1);
			if (err)
				return err;
			if (code == LOG_LEAF_REDIRECT) {
				err = replay_update_bitmap(rp, oldblock, 1, 0);
				if (err)
					return err;
			} else {
				/* newblock is not flushing yet */
				defer_bfree(&sb->deunify, oldblock, 1);
			}
			break;
		}
		case LOG_LEAF_FREE:
		case LOG_BNODE_FREE:
		{
			u64 block;
			data = decode48(data, &block);
			trace("%s: block %Lx", log_name[code], block);
			err = replay_update_bitmap(rp, block, 1, 0);
			if (err)
				return err;

			if (code == LOG_BNODE_FREE) {
				struct buffer_head *buffer =
					vol_find_get_block(sb, block);
				blockput_free_unify(sb, buffer);
			}
			break;
		}
		case LOG_BNODE_ROOT:
		{
			u64 root, left, right, rkey;
			u8 count;
			count = *data++;
			data = decode48(data, &root);
			data = decode48(data, &left);
			data = decode48(data, &right);
			data = decode48(data, &rkey);
			trace("%s: count %u, root block %Lx, left %Lx, right %Lx, rkey %Lx",
			      log_name[code], count, root, left, right, rkey);

			err = replay_update_bitmap(rp, root, 1, 1);
			if (err)
				return err;
			break;
		}
		case LOG_BNODE_SPLIT:
		{
			unsigned pos;
			u64 src, dst;
			data = decode16(data, &pos);
			data = decode48(data, &src);
			data = decode48(data, &dst);
			trace("%s: pos %x, src %Lx, dst %Lx",
			      log_name[code], pos, src, dst);
			err = replay_update_bitmap(rp, dst, 1, 1);
			if (err)
				return err;
			break;
		}
		case LOG_BNODE_MERGE:
		{
			u64 src, dst;
			data = decode48(data, &src);
			data = decode48(data, &dst);
			trace("%s: src 0x%Lx, dst 0x%Lx",
			      log_name[code], src, dst);
			err = replay_update_bitmap(rp, src, 1, 0);
			if (err)
				return err;

			blockput_free_unify(sb, vol_find_get_block(sb, src));
			break;
		}
		case LOG_ORPHAN_ADD:
		case LOG_ORPHAN_DEL:
		{
			unsigned version;
			u64 inum;
			data = decode16(data, &version);
			data = decode48(data, &inum);
			trace("%s: version 0x%x, inum 0x%Lx",
			      log_name[code], version, inum);
			if (code == LOG_ORPHAN_ADD)
				err = replay_orphan_add(rp, version, inum);
			else
				err = replay_orphan_del(rp, version, inum);
			if (err)
				return err;
			break;
		}
		case LOG_FREEBLOCKS:
		case LOG_BNODE_ADD:
		case LOG_BNODE_UPDATE:
		case LOG_BNODE_DEL:
		case LOG_BNODE_ADJUST:
		case LOG_UNIFY:
		case LOG_DELTA:
			data += log_size[code] - sizeof(code);
			break;
		default:
			tux3_err(sb, "unrecognized log code 0x%x", code);
			return -EINVAL;
		}
	}

	return 0;
}
Example #9
0
H_U32 _StorageUpdata(device_storage_gather_t *device_info)
{
	H_U32 retcode;
	WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"in __storage_device_updata");
	CHECK_PARAMETER(device_info, H_NULL, H_FAULTER);
	//H_U8 * buffer = H_NULL;
	//buffer = (H_U8 *)wy_malloc(STORAGE_BLOCK_LEN);
	//if( buffer == H_NULL)
	//{
	//	WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"malloc fail");
	//	return H_FAULTER;
	//}
	static H_U8 storage_buffer[STORAGE_BLOCK_LEN] = {0};
	H_U32 offset = 0;
	H_U32 magic_data = 0;

	wy_memset(storage_buffer,0xFF,STORAGE_BLOCK_LEN);
	//WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"reading entire block...");
	if(_StorageRead(device_info->handler, STORAGE_BLOCK_LEN,0,storage_buffer,device_info->user_block_size) != H_SUCCESS)
	{
		WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"read fail");
		//wy_free(buffer);
		//buffer = H_NULL;
		return H_FAULTER;
	}
	//WYPrintf_array(storage_buffer, STORAGE_BLOCK_LEN);
	wy_tools_op()->_delay_ms(10);
	offset = device_info->id * device_info->user_block_size ;
	WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"offset will be:%d",offset);
	magic_data = decode32(storage_buffer, offset);
	if(magic_data == device_info->magic_data || magic_data == 0) // check whether this block has been written before and is written by correct module
	{                                                          //workaround
		WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"magic1");
		if(device_info->magic_clear)//delete a record
		{
			WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"magic2");
			wy_memset(&(storage_buffer[offset]), 0xff, device_info->hand_len);
		}
		wy_memcpy(&(storage_buffer[offset + device_info->hand_len]), device_info->data, device_info->data_len);
	}
	else  //this block has not been written before 
	{
		if(!device_info->magic_clear)//add a record 
		{
			encode32(device_info->magic_data, storage_buffer, offset);
			wy_memcpy(&(storage_buffer[offset + device_info->hand_len]), device_info->data, device_info->data_len);
			
			WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"magic3:%x ",device_info->magic_data);
			
		}
	}
	retcode = _StorageErase(device_info->handler,STORAGE_BLOCK_LEN);
	WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"erasing module:%d block :%d",device_info->handler->module_id,device_info->handler->block_id);
	WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"ret of erase:%d",retcode);
	if(retcode  != H_SUCCESS)
		
	{
		WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"erase fail");
		//wy_free(buffer);
		//buffer = H_NULL;
		return H_FAULTER;
	}
	//wy_tools_op()->_delay_ms(100);
	//WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"before write1 for module:%d",device_info->handler->module_id);
	retcode = _StorageWrite(device_info->handler,storage_buffer,STORAGE_BLOCK_LEN, 0,device_info->user_block_size);
	WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"ret of write:%d  block size:%d",retcode,device_info->user_block_size);
	if(retcode != H_SUCCESS)
	{
		WYPrintf(MODULE_DEBUG_STORAGE,LEVEL_DEBUG,"rewrite fail");
		//wy_free(buffer);
		//buffer = H_NULL;
		return H_FAULTER;
	}
	wy_tools_op()->_delay_ms(100);
	//wy_free(buffer);
	//buffer = H_NULL;
	return H_SUCCESS;
}