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                         /* This test looks nicer. Thanks to Pauline Middelink */
  39                         if (!fsuser())
  40                                 return -EPERM;
  41                 } else
  42                         if ((current->fsuid != inode->i_uid) && !fsuser())
  43                                 return -EPERM;
  44                 if (IS_RDONLY(inode))
  45                         return -EROFS;
  46                 inode->u.ext2_i.i_flags = flags;
  47                 if (flags & EXT2_APPEND_FL)
  48                         inode->i_flags |= S_APPEND;
  49                 else
  50                         inode->i_flags &= ~S_APPEND;
  51                 if (flags & EXT2_IMMUTABLE_FL)
  52                         inode->i_flags |= S_IMMUTABLE;
  53                 else
  54                         inode->i_flags &= ~S_IMMUTABLE;
  55                 inode->i_ctime = CURRENT_TIME;
  56                 inode->i_dirt = 1;
  57                 return 0;
  58         case EXT2_IOC_GETVERSION:
  59                 if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
  60                         return err;
  61                 put_fs_long (inode->u.ext2_i.i_version, (long *) arg);
  62                 return 0;
  63         case EXT2_IOC_SETVERSION:
  64                 if ((current->fsuid != inode->i_uid) && !fsuser())
  65                         return -EPERM;
  66                 if (IS_RDONLY(inode))
  67                         return -EROFS;
  68                 inode->u.ext2_i.i_version = get_fs_long ((long *) arg);
  69                 inode->i_ctime = CURRENT_TIME;
  70                 inode->i_dirt = 1;
  71                 return 0;
  72         default:
  73                 return -EINVAL;
  74         }
  75 }

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