Open Source Telephony
 help / color / mirror / Atom feed
From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] simfs: make sim_fs_read_block work for > 256 byte files
Date: Mon, 29 Nov 2010 11:13:12 -0800	[thread overview]
Message-ID: <1291057992-14852-1-git-send-email-kristen@linux.intel.com> (raw)
In-Reply-To: <4CD026D7.5060806@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]

---
 src/simfs.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/simfs.c b/src/simfs.c
index 5f459ab..258a42f 100644
--- a/src/simfs.c
+++ b/src/simfs.c
@@ -59,6 +59,7 @@ static gboolean sim_fs_op_read_block(gpointer user_data);
 struct sim_fs_op {
 	int id;
 	unsigned char *buffer;
+	int bufoff;
 	enum ofono_sim_file_structure structure;
 	unsigned short offset;
 	gboolean info_only;
@@ -217,7 +218,6 @@ static void sim_fs_op_read_block_cb(const struct ofono_error *error,
 	struct sim_fs_op *op = g_queue_peek_head(fs->op_q);
 	int start_block;
 	int end_block;
-	int bufoff;
 	int dataoff;
 	int tocopy;
 
@@ -230,25 +230,25 @@ static void sim_fs_op_read_block_cb(const struct ofono_error *error,
 	end_block = (op->offset + (op->num_bytes - 1)) / 256;
 
 	if (op->current == start_block) {
-		bufoff = 0;
+		op->bufoff = 0;
 		dataoff = op->offset % 256;
 		tocopy = MIN(256 - op->offset % 256,
 				op->num_bytes - op->current * 256);
 	} else {
-		bufoff = (op->current - start_block - 1) * 256 +
-				op->offset % 256;
 		dataoff = 0;
 		tocopy = MIN(256, op->num_bytes - op->current * 256);
 	}
 
 	DBG("bufoff: %d, dataoff: %d, tocopy: %d",
-				bufoff, dataoff, tocopy);
+				op->bufoff, dataoff, tocopy);
 
-	memcpy(op->buffer + bufoff, data + dataoff, tocopy);
+	memcpy(op->buffer + op->bufoff, data + dataoff, tocopy);
 	cache_block(fs, op->current, 256, data, len);
 
 	op->current++;
 
+	op->bufoff += tocopy;
+
 	if (op->current > end_block) {
 		ofono_sim_file_read_cb_t cb = op->cb;
 
-- 
1.7.2.3


  reply	other threads:[~2010-11-29 19:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-04 22:33 [PATCH 0/4] Icon patches (rebased) Kristen Carlson Accardi
2010-10-04 22:33 ` [PATCH 1/4] simfs: cache images Kristen Carlson Accardi
2010-10-12  1:16   ` Denis Kenzior
2010-10-04 22:33 ` [PATCH 2/4] sim: implement GetIcon Kristen Carlson Accardi
2010-10-13 13:44   ` Denis Kenzior
2010-10-04 22:33 ` [PATCH 3/4] simfs: fix incorrect math when calculating length to copy Kristen Carlson Accardi
2010-10-13 13:44   ` Denis Kenzior
2010-10-14 18:18     ` [PATCH] simfs: fix incorrect math again Kristen Carlson Accardi
2010-11-02 14:41       ` Kristen Carlson Accardi
2010-11-02 14:57         ` Denis Kenzior
2010-11-29 19:13           ` Kristen Carlson Accardi [this message]
2010-10-04 22:33 ` [PATCH 4/4] simutil: add file type for EFimg Kristen Carlson Accardi
2010-10-12  3:16   ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291057992-14852-1-git-send-email-kristen@linux.intel.com \
    --to=kristen@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox