From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Fix the destroyed disk image partition table in a raw image file using Emacs. Date: Mon, 12 Apr 2021 14:29:09 +0800 Message-ID: References: <87tuocfx5g.fsf@no.workgroup> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35534"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 12 08:30:02 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVq5C-000983-0u for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 12 Apr 2021 08:30:02 +0200 Original-Received: from localhost ([::1]:41174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVq5B-0004Vv-1P for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 12 Apr 2021 02:30:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVq4b-0004Vd-7s for help-gnu-emacs@gnu.org; Mon, 12 Apr 2021 02:29:25 -0400 Original-Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:34703) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lVq4Z-0006T4-MI for help-gnu-emacs@gnu.org; Mon, 12 Apr 2021 02:29:25 -0400 Original-Received: by mail-lj1-x22c.google.com with SMTP id l14so11103650ljb.1 for ; Sun, 11 Apr 2021 23:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=2ZjiXfwqUYrUz5ZLq1lg0KsvHU100MACTWpHJ2nV88M=; b=dNiGnADEQJgXkzqxY9kYfgeT9dpDZ3aV18oig6cHzhxmW1N/mPHe9Z75UYF1ESX5xf duK6D0U0ByPSNMXtBbCd8A2Dw1ppkzgdHAGBF+1V/t/53cKjt543kJScwBOnrVsIHAaf P5rKHbjDc85kXenXoZulPaUSylXBP+RosjQt+Es34WkOy0G0XE2Og8Fxu9YsF8Sbo6fJ gWG99Irw05WTvrUw3/QefZGtCgg57Moay6unMmu02D3/oECqymR2W18sjDMaI8cvsTbL VgiuU3SMjVUmHpYdWyqvicz8MSRIzMeE93RBQcq/e/DDydkCwmLcg/adJUo9uHb0qywQ X+Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=2ZjiXfwqUYrUz5ZLq1lg0KsvHU100MACTWpHJ2nV88M=; b=iLQtJn05nJ3qAIjX5qk4ncEx6YvWxCXUTIFmYThKFjcNGLuUSzPRhQFPsSOjTszsBR 2hBHh9OXbF2rTV0OR91zhDyzw0tEj40kdccuONH/tKY2CvGEZv+6u5m/LfqjQelhFRMh ocXViEJBx2DzPUcXYTy8/eXVTsC2Wq5RPDKn10sQPWW+yL9HU8YrBicYRrDc/LSH105g m0cL9f0MozXey4CbYNL5Y6i/MB9Qur6JCiPvV6EwVfmZte7nSiX8jRvju0QLTqloRM4R J0ifPQsEBYIz7jNrg9M/srrkuu5x65XpYnOXqrwXcXp8ocrNmHdsqzNFhQ/xnQ+GN5CW 9SfQ== X-Gm-Message-State: AOAM533iocvDG9QYMhAeRE6qBwJFqAJHSYV2LmiCgQM9sEq3ulx3hToy I8gXuDmJjG2IyCmvY/RFxqf3Puyh/PmPC1NvApuhPU1b51exCeBv X-Google-Smtp-Source: ABdhPJxLn5m6oB12yefhyXNAJnFY7WGNc11yvZ80Nu4SU7L7VM4OxcXIke8g94jWlLrsOFhHyx1kTfKMvv6YHUO7PTw= X-Received: by 2002:a2e:700b:: with SMTP id l11mr3569396ljc.413.1618208961063; Sun, 11 Apr 2021 23:29:21 -0700 (PDT) In-Reply-To: <87tuocfx5g.fsf@no.workgroup> Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=hongyi.zhao@gmail.com; helo=mail-lj1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128963 Archived-At: On Mon, Apr 12, 2021 at 3:18 AM Gregor Zattler wrote: > > Hi Hongyi Zhao, > * Hongyi Zhao [2021-04-11; 21:34]: > > $ dd if=disk.img bs=1 count=4 skip=440 2>/dev/null | od -t x4 -An > > 761b36b0 > > > > It's well known that Emacs is an 8-bit clean editor which makes it > > safe to edit binary files. So, I want to whether I can fix the above > > destroyed disk image file with Emacs for my scenario. > > If your emacs is able to handle the disk image in memory > (which probably means you need a 64bit emacs and enough RAM > installed) you could open the file of the disk image with > > find-file-literally > > Visit file FILENAME with no conversion of any kind. > > Format conversion and character code conversion are both > disabled, and multibyte characters are disabled in the > resulting buffer. The major mode used is Fundamental > mode regardless of the file name, and local variable > specifications in the file are ignored. Automatic > uncompression and adding a newline at the end of the file > due to require-final-newline is also disabled. > > And then the first thing to do would be > > binary-overwrite-mode > > When Binary Overwrite mode is enabled, printing > characters typed in replace existing text. Newlines are > not treated specially, so typing at the end of a line > joins the line to the next, with the typed character > between them. Typing before a tab character simply > replaces the tab with the character typed. C-q replaces > the text at the cursor, just as ordinary typing > characters do. > > > You then can move point in the disk image to the desired > place and type in whatever you want and later save the > buffer to its file. Thank you so much for telling me this feature of Emacs. Regards -- Assoc. Prof. Hongyi Zhao Theory and Simulation of Materials Hebei Polytechnic University of Science and Technology engineering NO. 552 North Gangtie Road, Xingtai, China