root/fs/ext2/ioctl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ext2_ioctl

   1 /*
   2  * linux/fs/ext2/ioctl.c
   3  *
   4  * Copyright (C) 1993, 1994  Remy Card (card@masi.ibp.fr)
   5  *                           Laboratoire MASI - Institut Blaise Pascal
   6  *                           Universite Pierre et Marie Curie (Paris VI)
   7  */
   8 
   9 #include <asm/segment.h>
  10 
  11 #include <linux/errno.h>
  12 #include <linux/fs.h>
  13 #include <linux/ext2_fs.h>
  14 #include <linux/ioctl.h>
  15 #include <linux/sched.h>
  16 
  17 int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
     /* [previous][next][first][last][top][bottom][index][help] */
  18                 unsigned long arg)
  19 {
  20         int err;
  21         unsigned long flags;
  22 
  23         ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg);
  24 
  25         switch (cmd) {
  26         case EXT2_IOC_GETFLAGS:
  27                 if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
  28                         return err;
  29                 put_fs_long (inode->u.ext2_i.i_flags, (long *) arg);
  30                 return 0;
  31         case EXT2_IOC_SETFLAGS:
  32                 flags = get_fs_long ((long *) arg);
  33                 /*
  34                  * Only the super-user can change the IMMUTABLE flag
  35                  */
  36                 if (((flags & EXT2_IMMUTABLE_FL) &&
  37                      !(inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL)) ||
  38                     (!(flags & EXT2_IMMUTABLE_FL) &&
  39                      (inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL))) {
  40                         if (!fsuser())
  41                                 return -EPERM;
  42                 } else
  43                         if ((current->fsuid != inode->i_uid) && !fsuser())
  44                                 return -EPERM;
  45                 if (IS_RDONLY(inode))
  46                         return -EROFS;
  47                 inode->u.ext2_i.i_flags = flags;
  48                 if (flags & EXT2_APPEND_FL)
  49                         inode->i_flags |= S_APPEND;
  50                 else
  51                         inode->i_flags &= ~S_APPEND;
  52                 if (flags & EXT2_IMMUTABLE_FL)
  53                         inode->i_flags |= S_IMMUTABLE;
  54                 else
  55                         inode->i_flags &= ~S_IMMUTABLE;
  56                 inode->i_ctime = CURRENT_TIME;
  57                 inode->i_dirt = 1;
  58                 return 0;
  59         case EXT2_IOC_GETVERSION:
  60                 if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
  61                         return err;
  62                 put_fs_long (inode->u.ext2_i.i_version, (long *) arg);
  63                 return 0;
  64         case EXT2_IOC_SETVERSION:
  65                 if ((current->fsuid != inode->i_uid) && !fsuser())
  66                         return -EPERM;
  67                 if (IS_RDONLY(inode))
  68                         return -EROFS;
  69                 inode->u.ext2_i.i_version = get_fs_long ((long *) arg);
  70                 inode->i_ctime = CURRENT_TIME;
  71                 inode->i_dirt = 1;
  72                 return 0;
  73         default:
  74                 return -EINVAL;
  75         }
  76 }

/* [previous][next][first][last][top][bottom][index][help] */