flat assembler
Message board for the users of flat assembler.

Index > Linux > FASM File Overwriting

Author
Thread Post new topic Reply to topic
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 15 Mar 2015, 04:48
Now, this was undesirable...

Test #1:
0.Create a folder and go to there.
1.Create a file named "source.asm". In this case it is a very important file for you.
2.Create a file named "source.asm.temp". In this case it is just a temporary file you are testing some modifications or whatever you want.
3.Now assemble the file with fasm "fasm ./source.asm.temp"
4.Result, your original source is not your source anymore. Overwritten by FASM. o_O

Test #2:
0.Create a folder and go to there.
1.Create a file named "source". In this case it is a very important file for you.
2.Now assemble the file with fasm "fasm ./source"
3.Result, your original source is not your source anymore. Overwritten by FASM. o_O

While the auto overwrite functionality is welcome most of the time, I thought it would be nice to handle it with an extra care. D:

I thought it would create a file called "test" (Test #1), because "exe" files usually do not have any extension while most source files have. D:

I had the luck it was just a test and that was not an important file.

I will take more care next time. Or maybe start using the "fasm <input> <output>" template, I guess that is why it is there. D:

I apologize for wasting your time reading this.


Last edited by HaHaAnonymous on 15 Mar 2015, 14:35; edited 1 time in total
Post 15 Mar 2015, 04:48
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 15 Mar 2015, 08:53
Hm, interesting problem. It is because in Linux there is no dedicated extension for the executable files.
And I really can't imagine some reasonable way to handle it.
One possible way is to check the executable flag of the rewritten file.
If it is not set, the rewrite should fail. But such approach can fail on file systems that do not support UNIX file permissions - for example, if from Linux you try to compile on FAT or NTFS file system. In this case, depending on file system mounting options both are possible - file to be always rewritten and file to be never rewritten. Sad

P.S. HaHaAnonymous, having "important" files, not backed up is not good at all. I would suggest using some version control system for the important files. This way you can never lost them because of any reason, including hardware faults, bugs and wrongly typed "rm" command. Check Fossil SCM - it is the best tool I ever found for version control. And it is really easy to be used.
Post 15 Mar 2015, 08:53
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 15 Mar 2015, 11:03
I'm not sure how that's happened since the behaviour I observe is ".bin" is the default suffix so the output is "source.asm.bin"; if I try to force no extension I still get "source.asm." (something I'd hit a while ago without an indication of good-/bad-ness http://board.flatassembler.net/topic.php?t=13535). In my case, I was trying to overwrite the source file as part of a shared FASM/C build but since changed to longer naming that avoided the issue.

My steps were:
Quote:
#!/bin/bash

tmpdir=`mktemp -d`

cd $tmpdir

pwd

echo "(1)"

ls

echo "(2)"

echo "Test" > z.txt
more z.txt

ls

echo "(3)"

echo "" > z.txt.fasm
more z.txt.fasm

ls

echo "(4)"

fasm ./z.txt.fasm

ls

echo "(5)"

more z.txt

hexdump -x z.txt.bin

echo "(6)"

echo "format binary as ''" >> z.txt.fasm
more z.txt.fasm

echo "(7)"

fasm ./z.txt.fasm

ls

echo "(Cool"

more z.txt

hexdump -x z.txt.bin
which gave:
Quote:
bash fasm_test.bash
/tmp/tmp.uvgiIDMsvy
(1)
(2)
Test
z.txt
(3)

z.txt z.txt.fasm
(4)
flat assembler version 1.71.39 (16384 kilobytes memory)
1 passes, 0 bytes.
z.txt z.txt.bin z.txt.fasm
(5)
Test
(6)

format binary as ''
(7)
flat assembler version 1.71.39 (16384 kilobytes memory)
1 passes, 0 bytes.
z.txt z.txt. z.txt.bin z.txt.fasm
(Cool
Test
Question
Post 15 Mar 2015, 11:03
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 15 Mar 2015, 16:29
Quote:

P.S. HaHaAnonymous, having "important" files, not backed up is not good at all. I would suggest using some version control system for the important files. This way you can never lost them because of any reason, including hardware faults, bugs and wrongly typed "rm" command. Check Fossil SCM - it is the best tool I ever found for version control. And it is really easy to be used.

Thanks for the suggestion.

cod3b453
In my opinion, the "fasm <input> <output>" is the safest route. As nothing unexpected will be overwritten and you can name the way you want it.
Post 15 Mar 2015, 16:29
View user's profile Send private message Reply with quote
nkeck72



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
nkeck72 28 May 2015, 20:52
Quote:

Or maybe start using the "fasm <input> <output>" template, I guess that is why it is there. D:

Literally the first time you run ./fasm it is there.

also

Quote:

if from Linux you try to compile on FAT or NTFS file system. In this case, depending on file system mounting options both are possible - file to be always rewritten and file to be never rewritten.


I have had the same problem from both the Windows Console version and the DOS version. It's probably safest to go with ./fasm <input> <output>
Post 28 May 2015, 20:52
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.