LCOV - code coverage report
Current view: top level - fs/quota - kqid.c (source / functions) Hit Total Coverage
Test: gcov_data_raspi2_real_modules_combined.info Lines: 0 33 0.0 %
Date: 2020-09-30 20:25:40 Functions: 0 5 0.0 %
Branches: 0 26 0.0 %

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: GPL-2.0
       2                 :            : #include <linux/fs.h>
       3                 :            : #include <linux/quota.h>
       4                 :            : #include <linux/export.h>
       5                 :            : 
       6                 :            : /**
       7                 :            :  *      qid_eq - Test to see if to kquid values are the same
       8                 :            :  *      @left: A qid value
       9                 :            :  *      @right: Another quid value
      10                 :            :  *
      11                 :            :  *      Return true if the two qid values are equal and false otherwise.
      12                 :            :  */
      13                 :          0 : bool qid_eq(struct kqid left, struct kqid right)
      14                 :            : {
      15         [ #  # ]:          0 :         if (left.type != right.type)
      16                 :            :                 return false;
      17   [ #  #  #  # ]:          0 :         switch(left.type) {
      18                 :            :         case USRQUOTA:
      19                 :          0 :                 return uid_eq(left.uid, right.uid);
      20                 :            :         case GRPQUOTA:
      21                 :          0 :                 return gid_eq(left.gid, right.gid);
      22                 :            :         case PRJQUOTA:
      23                 :          0 :                 return projid_eq(left.projid, right.projid);
      24                 :            :         default:
      25                 :          0 :                 BUG();
      26                 :            :         }
      27                 :            : }
      28                 :            : EXPORT_SYMBOL(qid_eq);
      29                 :            : 
      30                 :            : /**
      31                 :            :  *      qid_lt - Test to see if one qid value is less than another
      32                 :            :  *      @left: The possibly lesser qid value
      33                 :            :  *      @right: The possibly greater qid value
      34                 :            :  *
      35                 :            :  *      Return true if left is less than right and false otherwise.
      36                 :            :  */
      37                 :          0 : bool qid_lt(struct kqid left, struct kqid right)
      38                 :            : {
      39         [ #  # ]:          0 :         if (left.type < right.type)
      40                 :            :                 return true;
      41         [ #  # ]:          0 :         if (left.type > right.type)
      42                 :            :                 return false;
      43   [ #  #  #  # ]:          0 :         switch (left.type) {
      44                 :            :         case USRQUOTA:
      45                 :          0 :                 return uid_lt(left.uid, right.uid);
      46                 :            :         case GRPQUOTA:
      47                 :          0 :                 return gid_lt(left.gid, right.gid);
      48                 :            :         case PRJQUOTA:
      49                 :          0 :                 return projid_lt(left.projid, right.projid);
      50                 :            :         default:
      51                 :          0 :                 BUG();
      52                 :            :         }
      53                 :            : }
      54                 :            : EXPORT_SYMBOL(qid_lt);
      55                 :            : 
      56                 :            : /**
      57                 :            :  *      from_kqid - Create a qid from a kqid user-namespace pair.
      58                 :            :  *      @targ: The user namespace we want a qid in.
      59                 :            :  *      @kqid: The kernel internal quota identifier to start with.
      60                 :            :  *
      61                 :            :  *      Map @kqid into the user-namespace specified by @targ and
      62                 :            :  *      return the resulting qid.
      63                 :            :  *
      64                 :            :  *      There is always a mapping into the initial user_namespace.
      65                 :            :  *
      66                 :            :  *      If @kqid has no mapping in @targ (qid_t)-1 is returned.
      67                 :            :  */
      68                 :          0 : qid_t from_kqid(struct user_namespace *targ, struct kqid kqid)
      69                 :            : {
      70   [ #  #  #  # ]:          0 :         switch (kqid.type) {
      71                 :            :         case USRQUOTA:
      72                 :          0 :                 return from_kuid(targ, kqid.uid);
      73                 :            :         case GRPQUOTA:
      74                 :          0 :                 return from_kgid(targ, kqid.gid);
      75                 :            :         case PRJQUOTA:
      76                 :          0 :                 return from_kprojid(targ, kqid.projid);
      77                 :            :         default:
      78                 :          0 :                 BUG();
      79                 :            :         }
      80                 :            : }
      81                 :            : EXPORT_SYMBOL(from_kqid);
      82                 :            : 
      83                 :            : /**
      84                 :            :  *      from_kqid_munged - Create a qid from a kqid user-namespace pair.
      85                 :            :  *      @targ: The user namespace we want a qid in.
      86                 :            :  *      @kqid: The kernel internal quota identifier to start with.
      87                 :            :  *
      88                 :            :  *      Map @kqid into the user-namespace specified by @targ and
      89                 :            :  *      return the resulting qid.
      90                 :            :  *
      91                 :            :  *      There is always a mapping into the initial user_namespace.
      92                 :            :  *
      93                 :            :  *      Unlike from_kqid from_kqid_munged never fails and always
      94                 :            :  *      returns a valid projid.  This makes from_kqid_munged
      95                 :            :  *      appropriate for use in places where failing to provide
      96                 :            :  *      a qid_t is not a good option.
      97                 :            :  *
      98                 :            :  *      If @kqid has no mapping in @targ the kqid.type specific
      99                 :            :  *      overflow identifier is returned.
     100                 :            :  */
     101                 :          0 : qid_t from_kqid_munged(struct user_namespace *targ, struct kqid kqid)
     102                 :            : {
     103   [ #  #  #  # ]:          0 :         switch (kqid.type) {
     104                 :            :         case USRQUOTA:
     105                 :          0 :                 return from_kuid_munged(targ, kqid.uid);
     106                 :            :         case GRPQUOTA:
     107                 :          0 :                 return from_kgid_munged(targ, kqid.gid);
     108                 :            :         case PRJQUOTA:
     109                 :          0 :                 return from_kprojid_munged(targ, kqid.projid);
     110                 :            :         default:
     111                 :          0 :                 BUG();
     112                 :            :         }
     113                 :            : }
     114                 :            : EXPORT_SYMBOL(from_kqid_munged);
     115                 :            : 
     116                 :            : /**
     117                 :            :  *      qid_valid - Report if a valid value is stored in a kqid.
     118                 :            :  *      @qid: The kernel internal quota identifier to test.
     119                 :            :  */
     120                 :          0 : bool qid_valid(struct kqid qid)
     121                 :            : {
     122   [ #  #  #  # ]:          0 :         switch (qid.type) {
     123                 :            :         case USRQUOTA:
     124                 :          0 :                 return uid_valid(qid.uid);
     125                 :            :         case GRPQUOTA:
     126                 :          0 :                 return gid_valid(qid.gid);
     127                 :            :         case PRJQUOTA:
     128                 :          0 :                 return projid_valid(qid.projid);
     129                 :            :         default:
     130                 :          0 :                 BUG();
     131                 :            :         }
     132                 :            : }
     133                 :            : EXPORT_SYMBOL(qid_valid);

Generated by: LCOV version 1.14