How to read Linux File attributes?

Kernel, Loader, code execution and working with memory

How to read Linux File attributes?

Postby Zinn » Sat Apr 18, 2020 9:17 am

Another question is: How to read the attributes of a Linux file or Linux directory from BlackBox?
Is there a call available via the Lin library? Where can I find a description or an explanation about the Lin library?
- Helmut
Zinn
 
Posts: 83
Joined: Mon Nov 24, 2014 10:47 am
Location: Frankfurt am Main

Re: How to read Linux File attributes?

Postby Ivan Denisov » Wed Apr 22, 2020 3:12 pm

I got some copypaste from HostFiles. Information about libc library you can find in the Internet documentation for Linux.

Code: Select all
MODULE DemoRun;
   IMPORT  Log, Libc := LinLibc, HostFiles, Strings;
   
   TYPE
      ShortName = ARRAY 260 * 4 OF SHORTCHAR;
   
   PROCEDURE Stat*;
   CONST
      read = 8;
      write = 7;
      execute = 6;
      file = 15;
      
      VAR s: ShortName; ok1, res: INTEGER; buf: Libc.stat_t;
   BEGIN
      Strings.StringToUtf8('/home/dia/blackbox/test', s, ok1);
      res := Libc.__xstat(Libc._STAT_VER_LINUX, s, buf); (* macro expansion of "stat" *)
      Log.String("is directory "); Log.Bool(~ (file IN buf.st_mode)); Log.Ln;
      Log.String("all bits "); Log.Set(buf.st_mode); Log.Ln;
      
   END Stat;

END DemoRun.
User avatar
Ivan Denisov
 
Posts: 283
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia


Return to System

Who is online

Users browsing this forum: No registered users and 2 guests

cron