Index: common/textfile.c =================================================================== RCS file: /cvsroot/bluez/utils/common/textfile.c,v retrieving revision 1.6 diff -u -r1.6 textfile.c --- common/textfile.c 30 Aug 2005 00:35:39 -0000 1.6 +++ common/textfile.c 7 Sep 2005 11:06:43 -0000 @@ -180,8 +180,14 @@ end += len; len = size - (end - map); - - if (len <= 0 || len > size) { + if (!len) { + munmap(map, size); + ftruncate(fd, base); + pos = lseek(fd, base, SEEK_SET); + err = write_key_value(fd, key, value); + goto unlock; + } + if (len < 0 || len > size) { err = EILSEQ; goto unmap; }