[PATCH] simplify shmem_aops.set_page_dirty() method
[sfrench/cifs-2.6.git] / include / linux / key.h
index 53513a3be53ba745ad900fae33d7727c0dbaca9b..169f05e4863ed140058674a1e5a1fcab5f06f766 100644 (file)
@@ -177,6 +177,9 @@ struct key {
 /*
  * kernel managed key type definition
  */
+typedef int (*request_key_actor_t)(struct key *key, struct key *authkey,
+                                  const char *op, void *aux);
+
 struct key_type {
        /* name of the type */
        const char *name;
@@ -193,14 +196,6 @@ struct key_type {
         */
        int (*instantiate)(struct key *key, const void *data, size_t datalen);
 
-       /* duplicate a key of this type (optional)
-        * - the source key will be locked against change
-        * - the new description will be attached
-        * - the quota will have been adjusted automatically from
-        *   source->quotalen
-        */
-       int (*duplicate)(struct key *key, const struct key *source);
-
        /* update a key of this type (optional)
         * - this method should call key_payload_reserve() to recalculate the
         *   quota consumption
@@ -211,6 +206,11 @@ struct key_type {
        /* match a key against a description */
        int (*match)(const struct key *key, const void *desc);
 
+       /* clear some of the data from a key on revokation (optional)
+        * - the key's semaphore will be write-locked by the caller
+        */
+       void (*revoke)(struct key *key);
+
        /* clear the data from a key (optional) */
        void (*destroy)(struct key *key);
 
@@ -226,6 +226,16 @@ struct key_type {
         */
        long (*read)(const struct key *key, char __user *buffer, size_t buflen);
 
+       /* handle request_key() for this type instead of invoking
+        * /sbin/request-key (optional)
+        * - key is the key to instantiate
+        * - authkey is the authority to assume when instantiating this key
+        * - op is the operation to be done, usually "create"
+        * - the call must not return until the instantiation process has run
+        *   its course
+        */
+       request_key_actor_t request_key;
+
        /* internal fields */
        struct list_head        link;           /* link in types list */
 };
@@ -237,8 +247,16 @@ extern void unregister_key_type(struct key_type *ktype);
 
 extern struct key *key_alloc(struct key_type *type,
                             const char *desc,
-                            uid_t uid, gid_t gid, key_perm_t perm,
-                            int not_in_quota);
+                            uid_t uid, gid_t gid,
+                            struct task_struct *ctx,
+                            key_perm_t perm,
+                            unsigned long flags);
+
+
+#define KEY_ALLOC_IN_QUOTA     0x0000  /* add to quota, reject if would overrun */
+#define KEY_ALLOC_QUOTA_OVERRUN        0x0001  /* add to quota, permit even if overrun */
+#define KEY_ALLOC_NOT_IN_QUOTA 0x0002  /* not in quota */
+
 extern int key_payload_reserve(struct key *key, size_t datalen);
 extern int key_instantiate_and_link(struct key *key,
                                    const void *data,
@@ -268,6 +286,11 @@ extern struct key *request_key(struct key_type *type,
                               const char *description,
                               const char *callout_info);
 
+extern struct key *request_key_with_auxdata(struct key_type *type,
+                                           const char *description,
+                                           const char *callout_info,
+                                           void *aux);
+
 extern int key_validate(struct key *key);
 
 extern key_ref_t key_create_or_update(key_ref_t keyring,
@@ -275,7 +298,7 @@ extern key_ref_t key_create_or_update(key_ref_t keyring,
                                      const char *description,
                                      const void *payload,
                                      size_t plen,
-                                     int not_in_quota);
+                                     unsigned long flags);
 
 extern int key_update(key_ref_t key,
                      const void *payload,
@@ -288,7 +311,9 @@ extern int key_unlink(struct key *keyring,
                      struct key *key);
 
 extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,
-                                int not_in_quota, struct key *dest);
+                                struct task_struct *ctx,
+                                unsigned long flags,
+                                struct key *dest);
 
 extern int keyring_clear(struct key *keyring);
 
@@ -309,7 +334,8 @@ extern void keyring_replace_payload(struct key *key, void *replacement);
  * the userspace interface
  */
 extern struct key root_user_keyring, root_session_keyring;
-extern int alloc_uid_keyring(struct user_struct *user);
+extern int alloc_uid_keyring(struct user_struct *user,
+                            struct task_struct *ctx);
 extern void switch_uid_keyring(struct user_struct *new_user);
 extern int copy_keys(unsigned long clone_flags, struct task_struct *tsk);
 extern int copy_thread_group_keys(struct task_struct *tsk);
@@ -338,7 +364,7 @@ extern void key_init(void);
 #define make_key_ref(k)                        ({ NULL; })
 #define key_ref_to_ptr(k)              ({ NULL; })
 #define is_key_possessed(k)            0
-#define alloc_uid_keyring(u)           0
+#define alloc_uid_keyring(u,c)         0
 #define switch_uid_keyring(u)          do { } while(0)
 #define __install_session_keyring(t, k)        ({ NULL; })
 #define copy_keys(f,t)                 0
@@ -351,6 +377,10 @@ extern void key_init(void);
 #define key_fsgid_changed(t)           do { } while(0)
 #define key_init()                     do { } while(0)
 
+/* Initial keyrings */
+extern struct key root_user_keyring;
+extern struct key root_session_keyring;
+
 #endif /* CONFIG_KEYS */
 #endif /* __KERNEL__ */
 #endif /* _LINUX_KEY_H */