79380303

Date: 2025-01-23 08:24:43
Score: 3
Natty:
Report link

I am answering https://stackoverflow.com/users/10147399/aykhan-hagverdili since I don't have enough rep to comment:

creat is defined as:

SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, mode)
{
    int flags = O_CREAT | O_WRONLY | O_TRUNC;

    if (force_o_largefile())
        flags |= O_LARGEFILE;
    return do_sys_open(AT_FDCWD, pathname, flags, mode);
}

whereas open is defined as:

SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
{
    if (force_o_largefile())
        flags |= O_LARGEFILE;
    return do_sys_open(AT_FDCWD, filename, flags, mode);
}

SYSCALL_DEFINEX defines a syscall that takes in x arguments as input. It should be easy to see creat is just a specialized open with flags O_WRONLY|O_CREAT|O_TRUNC

References:

https://elixir.bootlin.com/linux/v6.13-rc3/source/fs/open.c#L1421

https://elixir.bootlin.com/linux/v6.13-rc3/source/fs/open.c#L1489

Reasons:
  • Blacklisted phrase (1): to comment
  • Blacklisted phrase (1): stackoverflow
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: CraftyDrake