git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] write_sha1_buffer

From
MWMorten Welinder <mwelinder@gmail.com>
Date
Apr 16, 2005, 00:50 UTC
Message-ID
<118833cc05041517502fa52a89@mail.gmail.com>

This write will failing sooner or later when someone's disk fills up. That'll leave someone with a truncated file.

Signed-off-by: Morten Welinder <mwelinder@gmail.com>

--- read-cache.c +++ read-cache.c 2005-04-15 20:32:52.111187168 -0400

@@ -276,9 +276,13 @@
                                        " This is bad, bad, BAD!\a\n");
                return 0;
        }
-       write(fd, buf, size);
-       close(fd);
-       return 0;
+
+       if (write(fd, buf, size) != size) {
+               close(fd);
+               return error("Failed to write file %s\n", filename);
+       }
+
+       return close(fd);
 }
Next: Linus Torvalds
Message 1 of 3 in “write_sha1_buffer”
  1. write_sha1_bufferMorten Welinder, Apr 16, 2005
  2. Linus TorvaldsApr 16, 2005
  3. Linus TorvaldsApr 16, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.