aboutsummaryrefslogtreecommitdiff
path: root/src/lib/fileHandling.s
diff options
context:
space:
mode:
authormithe24 <mithe24@student.sdu.dk>2025-10-08 13:35:41 +0200
committermithe24 <mithe24@student.sdu.dk>2025-10-29 13:49:57 +0100
commitfa03afa46984fbf6eacbd5540e4e318d161cbbe0 (patch)
treecd5e2f567a407ee459d94fcfd8ed3088fce3bc96 /src/lib/fileHandling.s
parent07816c4c9c257c327bb93a72ed3a9b680816136c (diff)
downloadsorter-fa03afa46984fbf6eacbd5540e4e318d161cbbe0.tar.gz
sorter-fa03afa46984fbf6eacbd5540e4e318d161cbbe0.zip
chore(snippets): move snippetss to src/
Diffstat (limited to 'src/lib/fileHandling.s')
-rw-r--r--src/lib/fileHandling.s16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/fileHandling.s b/src/lib/fileHandling.s
new file mode 100644
index 0000000..17a9428
--- /dev/null
+++ b/src/lib/fileHandling.s
@@ -0,0 +1,16 @@
+# int getFileSize(int fd)
+#
+# Returns the size (in bytes) of the file indicated by the file descriptor.
+.section .data
+.Lstat: .space 144 # size of the fstat struct
+.section .text
+.globl getFileSize
+.type getFileSize, @function
+getFileSize:
+ movq $5, %rax # fstat
+ # rdi already contains the fd
+ movq $.Lstat, %rsi # buffer to write fstat data into
+ syscall
+ movq $.Lstat, %rax
+ movq 48(%rax), %rax # position of size in the struct
+ ret