<commit_before>/* SPDX-License-Identifier: BSD-2-Clause */

static ramfs_inode *ramfs_new_inode(ramfs_data *d)
{
   ramfs_inode *i = kzmalloc(sizeof(ramfs_inode));

   if (!i)
      return NULL;

   i->type = VFS_NONE;
   rwlock_wp_init(&i->rwlock, true);
   i->ino = d->next_inode_num++;
   return i;
}

static ramfs_inode *
ramfs_create_inode_dir(ramfs_data *d, mode_t mode, ramfs_inode *parent)
{
   ramfs_inode *i = ramfs_new_inode(d);

   if (!i)
      return NULL;

   i->type = VFS_DIR;
   i->mode = (mode & 0777) | S_IFDIR;
   list_init(&i->entries_list);
   list_init(&i->handles_list);

   if (!parent) {
      /* root case */
      parent = i;
   }<commit_msg>[debug][ramfs] Add a nice debug option for tracking the creation of inodes<commit_after>/* SPDX-License-Identifier: BSD-2-Clause */

#define DEBUG_RAMFS_CREATE_INODE_PRINTK      0

static ramfs_inode *ramfs_new_inode(ramfs_data *d)
{
   ramfs_inode *i = kzmalloc(sizeof(ramfs_inode));

   if (!i)
      return NULL;

   i->type = VFS_NONE;
   rwlock_wp_init(&i->rwlock, true);
   i->ino = d->next_inode_num++;

   if (DEBUG_RAMFS_CREATE_INODE_PRINTK) {
      printk("[ramfs] Create inode with ref_count at %p\n", &i->ref_count);
   }

   return i;
}

static ramfs_inode *
ramfs_create_inode_dir(ramfs_data *d, mode_t mode, ramfs_inode *parent)
{
   ramfs_inode *i = ramfs_new_inode(d);

   if (!i)
      return NULL;

   i->type = VFS_DIR;
   i->mode = (mode & 0777) | S_IFDIR;
   list_init(&i->entries_list);
   list_init(&i->handles_list);

   if (!parent) {
      /* root case */
      parent = i;
   }
{'fraction_non_alphanumeric': 0.14213197969543148, 'fraction_numerical': 0.006979695431472081, 'mean_word_length': 3.3443526170798896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6856605', 'n_tokens_mistral': 646, 'n_tokens_neox': 621, 'n_words': 126}